Skip to content

Commit 120533a

Browse files
committed
fix: correct multi-account TGW share
1 parent 3b70cc0 commit 120533a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/multi-account/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ module "tgw_peer" {
8787
description = "My TGW shared with several other AWS accounts"
8888
amazon_side_asn = 64532
8989

90-
share_tgw = true
9190
create_tgw = false
91+
share_tgw = true
9292
ram_resource_share_arn = module.tgw.ram_resource_share_id
9393
enable_auto_accept_shared_attachments = true # When "true" there is no need for RAM resources if using multiple AWS accounts
9494

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
locals {
22
# List of maps with key and route values
33
vpc_attachments_with_routes = chunklist(flatten([
4-
for k, v in var.vpc_attachments : setproduct([{ key = k }], v.tgw_routes) if can(v.tgw_routes)
4+
for k, v in var.vpc_attachments : setproduct([{ key = k }], v.tgw_routes) if var.create_tgw && can(v.tgw_routes)
55
]), 2)
66

77
tgw_default_route_table_tags_merged = merge(
@@ -110,7 +110,7 @@ resource "aws_route" "this" {
110110

111111
resource "aws_ec2_transit_gateway_route_table_association" "this" {
112112
for_each = {
113-
for k, v in var.vpc_attachments : k => v if try(v.transit_gateway_default_route_table_association, true) != true
113+
for k, v in var.vpc_attachments : k => v if var.create_tgw && try(v.transit_gateway_default_route_table_association, true) != true
114114
}
115115

116116
# Create association if it was not set already by aws_ec2_transit_gateway_vpc_attachment resource
@@ -120,7 +120,7 @@ resource "aws_ec2_transit_gateway_route_table_association" "this" {
120120

121121
resource "aws_ec2_transit_gateway_route_table_propagation" "this" {
122122
for_each = {
123-
for k, v in var.vpc_attachments : k => v if try(v.transit_gateway_default_route_table_propagation, true) != true
123+
for k, v in var.vpc_attachments : k => v if var.create_tgw && try(v.transit_gateway_default_route_table_propagation, true) != true
124124
}
125125

126126
# Create association if it was not set already by aws_ec2_transit_gateway_vpc_attachment resource

0 commit comments

Comments
 (0)