Skip to content

Commit

Permalink
WIP - Add Elastic IP tags (#74)
Browse files Browse the repository at this point in the history
* Update eip.tf

* add variable

* removed variable from top level module and added name prefix logic to single cluster module
  • Loading branch information
Azahorscak authored Apr 7, 2022
1 parent 027d248 commit 091aa1d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion eip.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

resource "aws_eip" "mod_nat" {
count = var.multi_az_nat_gateway * var.az_count + var.single_nat_gateway * 1
tags = var.global_tags
tags = var.global_tags
vpc = true
}

Expand Down
16 changes: 12 additions & 4 deletions modules/single-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,26 @@ variable "extra_tags_private_subnet" {
default = {}
}

## Tagging Settings
variable "elastic_ip_name_prefix" {
type = string
description = "The name prefix for each eip."
default = ""
}

# Local Vars
locals {
eip_name_prefix = length(var.elastic_ip_name_prefix) > 0 ? "${var.elastic_ip_name_prefix}-" : ""
default_tags = {
"ManagedVia" = "Terraform"
"Author" = "Fairwinds"
}

tags = merge(local.default_tags, var.extra_tags_global)
admin_subnet_tags = merge(local.tags, var.extra_tags_admin_subnet)
tags = merge(local.default_tags, var.extra_tags_global)
admin_subnet_tags = merge(local.tags, var.extra_tags_admin_subnet)
private_subnet_tags = merge(local.tags, var.extra_tags_private_subnet)
public_subnet_tags = merge(local.tags, var.extra_tags_public_subnet)
avail_zones_list = split(",", var.availability_zones)
public_subnet_tags = merge(local.tags, var.extra_tags_public_subnet)
avail_zones_list = split(",", var.availability_zones)
}

# Usage validation
Expand Down
9 changes: 7 additions & 2 deletions modules/single-cluster/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ resource "aws_nat_gateway" "nat_gateway" {

resource "aws_eip" "mod_nat" {
count = length(local.avail_zones_list)
tags = local.tags
vpc = true
tags = merge(
local.tags,
{
"Name" = "${local.eip_name_prefix}${var.vpc_name}_${local.avail_zones_list[count.index]}"
},
)
vpc = true
}

output "aws_eip_nat_ips" {
Expand Down
14 changes: 7 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,30 @@ POLICY

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

variable "internet_gateway_tags" {
description = "Tags to apply to the internet gateway"
default = {}
default = {}
}

variable "public_route_table_tags" {
description = "Tags to apply to the public route table"
default = {}
default = {}
}

variable "private_route_table_tags" {
description = "Tags to apply to the private route table"
default = {}
default = {}
}

variable "global_tags" {
description = "AWS tags that will be added to all resources managed herein"
type = map(string)
type = map(string)
default = {
"Author" = "Fairwinds"
"Author" = "Fairwinds"
"Managed By" = "Terraform"
}
}
Expand Down

0 comments on commit 091aa1d

Please sign in to comment.