Skip to content

Commit 091aa1d

Browse files
authored
WIP - Add Elastic IP tags (#74)
* Update eip.tf * add variable * removed variable from top level module and added name prefix logic to single cluster module
1 parent 027d248 commit 091aa1d

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

eip.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
resource "aws_eip" "mod_nat" {
1616
count = var.multi_az_nat_gateway * var.az_count + var.single_nat_gateway * 1
17-
tags = var.global_tags
17+
tags = var.global_tags
1818
vpc = true
1919
}
2020

modules/single-cluster/variables.tf

+12-4
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,26 @@ variable "extra_tags_private_subnet" {
7979
default = {}
8080
}
8181

82+
## Tagging Settings
83+
variable "elastic_ip_name_prefix" {
84+
type = string
85+
description = "The name prefix for each eip."
86+
default = ""
87+
}
88+
8289
# Local Vars
8390
locals {
91+
eip_name_prefix = length(var.elastic_ip_name_prefix) > 0 ? "${var.elastic_ip_name_prefix}-" : ""
8492
default_tags = {
8593
"ManagedVia" = "Terraform"
8694
"Author" = "Fairwinds"
8795
}
8896

89-
tags = merge(local.default_tags, var.extra_tags_global)
90-
admin_subnet_tags = merge(local.tags, var.extra_tags_admin_subnet)
97+
tags = merge(local.default_tags, var.extra_tags_global)
98+
admin_subnet_tags = merge(local.tags, var.extra_tags_admin_subnet)
9199
private_subnet_tags = merge(local.tags, var.extra_tags_private_subnet)
92-
public_subnet_tags = merge(local.tags, var.extra_tags_public_subnet)
93-
avail_zones_list = split(",", var.availability_zones)
100+
public_subnet_tags = merge(local.tags, var.extra_tags_public_subnet)
101+
avail_zones_list = split(",", var.availability_zones)
94102
}
95103

96104
# Usage validation

modules/single-cluster/vpc.tf

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ resource "aws_nat_gateway" "nat_gateway" {
5959

6060
resource "aws_eip" "mod_nat" {
6161
count = length(local.avail_zones_list)
62-
tags = local.tags
63-
vpc = true
62+
tags = merge(
63+
local.tags,
64+
{
65+
"Name" = "${local.eip_name_prefix}${var.vpc_name}_${local.avail_zones_list[count.index]}"
66+
},
67+
)
68+
vpc = true
6469
}
6570

6671
output "aws_eip_nat_ips" {

variables.tf

+7-7
Original file line numberDiff line numberDiff line change
@@ -165,30 +165,30 @@ POLICY
165165

166166
variable "s3_vpc_endpoint_route_table_ids" {
167167
description = "By default routes to the s3 endpoint are added for private subnet route tables. Pass additional route table ids that require routes."
168-
type = list(string)
169-
default = []
168+
type = list(string)
169+
default = []
170170
}
171171

172172
variable "internet_gateway_tags" {
173173
description = "Tags to apply to the internet gateway"
174-
default = {}
174+
default = {}
175175
}
176176

177177
variable "public_route_table_tags" {
178178
description = "Tags to apply to the public route table"
179-
default = {}
179+
default = {}
180180
}
181181

182182
variable "private_route_table_tags" {
183183
description = "Tags to apply to the private route table"
184-
default = {}
184+
default = {}
185185
}
186186

187187
variable "global_tags" {
188188
description = "AWS tags that will be added to all resources managed herein"
189-
type = map(string)
189+
type = map(string)
190190
default = {
191-
"Author" = "Fairwinds"
191+
"Author" = "Fairwinds"
192192
"Managed By" = "Terraform"
193193
}
194194
}

0 commit comments

Comments
 (0)