Skip to content

Commit

Permalink
Add protection tag in locals
Browse files Browse the repository at this point in the history
  • Loading branch information
lgallard committed Sep 1, 2021
1 parent 30bd887 commit a57f457
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions network/transit-gateway/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
tags = {
Terraform = "true"
Environment = var.environment
protection = "on"
}
}

Expand Down
4 changes: 1 addition & 3 deletions network/transit-gateway/tgw.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ module "tgw" {
} : {},
)

tags = {
Name = "${var.project}-${var.environment}-tgw"
}
tags = local.tags

providers = {
aws = aws.network
Expand Down
26 changes: 13 additions & 13 deletions network/transit-gateway/vpc_attachments.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module "tgw_vpc_attachments_and_subnet_routes_network_firewall" {
k => v if var.enable_tgw && var.enable_network_firewall && lookup(var.enable_vpc_attach, "network", false)
}

name = "${var.project}-${each.key}-vpc"

# network account can access the Transit Gateway in the network: account since we shared the Transit Gateway with the Organization using Resource Access Manager
existing_transit_gateway_id = module.tgw[0].transit_gateway_id
create_transit_gateway = false
Expand All @@ -44,9 +46,7 @@ module "tgw_vpc_attachments_and_subnet_routes_network_firewall" {
}
}

tags = {
Name = "${var.project}-${each.key}-vpc"
}
tags = local.tags

providers = {
aws = aws.network
Expand All @@ -63,6 +63,8 @@ module "tgw_vpc_attachments_and_subnet_routes_network" {
k => v if var.enable_tgw && lookup(var.enable_vpc_attach, "network", false)
}

name = "${var.project}-${each.key}-vpc"

# network account can access the Transit Gateway in the network: account since we shared the Transit Gateway with the Organization using Resource Access Manager
existing_transit_gateway_id = module.tgw[0].transit_gateway_id
existing_transit_gateway_route_table_id = module.tgw[0].transit_gateway_route_table_id
Expand All @@ -84,9 +86,7 @@ module "tgw_vpc_attachments_and_subnet_routes_network" {
}
}

tags = {
Name = "${var.project}-${each.key}-vpc"
}
tags = local.tags

providers = {
aws = aws.network
Expand All @@ -103,6 +103,8 @@ module "tgw_vpc_attachments_and_subnet_routes_apps-devstg" {
k => v if var.enable_tgw && lookup(var.enable_vpc_attach, "apps-devstg", false)
}

name = "${var.project}-${each.key}-vpc"

# apps-devstg account can access the Transit Gateway in the network account since we shared the Transit Gateway with the Organization using Resource Access Manager
existing_transit_gateway_id = module.tgw[0].transit_gateway_id
existing_transit_gateway_route_table_id = var.enable_tgw && var.enable_network_firewall ? module.tgw_vpc_attachments_and_subnet_routes_network_firewall["network-firewall"].transit_gateway_route_table_id : module.tgw[0].transit_gateway_route_table_id
Expand All @@ -128,9 +130,7 @@ module "tgw_vpc_attachments_and_subnet_routes_apps-devstg" {
}
}

tags = {
Name = "${var.project}-apps-devstg-vpc"
}
tags = local.tags

providers = {
aws = aws.apps-devstg
Expand All @@ -147,7 +147,7 @@ module "tgw_vpc_attachments_and_subnet_routes_apps-prd" {
k => v if var.enable_tgw && lookup(var.enable_vpc_attach, "apps-prd", false)
}

name = "${var.project}-apps-prd-vpc"
name = "${var.project}-${each.key}-vpc"

# apps-prd account can access the Transit Gateway in the network account since we shared the Transit Gateway with the Organization using Resource Access Manager
existing_transit_gateway_id = module.tgw[0].transit_gateway_id
Expand Down Expand Up @@ -191,6 +191,8 @@ module "tgw_vpc_attachments_and_subnet_routes_shared" {
k => v if var.enable_tgw && lookup(var.enable_vpc_attach, "shared", false)
}

name = "${var.project}-${each.key}-vpc"

# apps-devstg account can access the Transit Gateway in the network account since we shared the Transit Gateway with the Organization using Resource Access Manager
existing_transit_gateway_id = module.tgw[0].transit_gateway_id
existing_transit_gateway_route_table_id = var.enable_tgw && lookup(var.enable_vpc_attach, "shared", false) ? try(module.tgw_vpc_attachments_and_subnet_routes_network_firewall["network-firewall"].transit_gateway_route_table_id, null) : module.tgw[0].transit_gateway_route_table_id
Expand All @@ -215,9 +217,7 @@ module "tgw_vpc_attachments_and_subnet_routes_shared" {
}
}

tags = {
Name = "${var.project}-shared-vpc"
}
tags = local.tags

providers = {
aws = aws.shared
Expand Down

0 comments on commit a57f457

Please sign in to comment.