Skip to content

Commit 8f49de5

Browse files
committed
Fix bug in ram-shared transit gateway vpc attachment
1 parent 5ea987b commit 8f49de5

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

modules/subnet-group/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ This module creates following resources.
4848
| [aws_redshift_subnet_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_subnet_group) | resource |
4949
| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
5050
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
51+
| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
52+
| [aws_ec2_transit_gateway.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway) | data source |
5153

5254
## Inputs
5355

modules/subnet-group/integrations.tf

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
data "aws_caller_identity" "this" {}
2+
3+
locals {
4+
account_id = data.aws_caller_identity.this.account_id
5+
}
6+
7+
18
###################################################
29
# VPC Attachments for Transit Gateway
310
###################################################
411

12+
data "aws_ec2_transit_gateway" "this" {
13+
for_each = {
14+
for attachment in var.transit_gateway_attachments :
15+
attachment.name => attachment.transit_gateway
16+
}
17+
18+
filter {
19+
name = "transit-gateway-id"
20+
values = [each.value]
21+
}
22+
}
23+
524
resource "aws_ec2_transit_gateway_vpc_attachment" "this" {
625
for_each = {
726
for attachment in var.transit_gateway_attachments :
@@ -13,11 +32,17 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "this" {
1332

1433
transit_gateway_id = each.value.transit_gateway
1534

16-
appliance_mode_support = each.value.appliance_mode_enabled ? "enable" : "disable"
17-
dns_support = each.value.dns_support_enabled ? "enable" : "disable"
18-
ipv6_support = each.value.ipv6_enabled ? "enable" : "disable"
19-
transit_gateway_default_route_table_association = each.value.default_association_route_table_enabled
20-
transit_gateway_default_route_table_propagation = each.value.default_propagation_route_table_enabled
35+
appliance_mode_support = each.value.appliance_mode_enabled ? "enable" : "disable"
36+
dns_support = each.value.dns_support_enabled ? "enable" : "disable"
37+
ipv6_support = each.value.ipv6_enabled ? "enable" : "disable"
38+
transit_gateway_default_route_table_association = (local.account_id == data.aws_ec2_transit_gateway.this[each.key].owner_id
39+
? each.value.default_association_route_table_enabled
40+
: null
41+
)
42+
transit_gateway_default_route_table_propagation = (local.account_id == data.aws_ec2_transit_gateway.this[each.key].owner_id
43+
? each.value.default_propagation_route_table_enabled
44+
: null
45+
)
2146

2247
tags = merge(
2348
{

0 commit comments

Comments
 (0)