Skip to content

Commit

Permalink
Fix bug in ram-shared transit gateway vpc attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed Feb 23, 2024
1 parent 5ea987b commit 8f49de5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions modules/subnet-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ This module creates following resources.
| [aws_redshift_subnet_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_subnet_group) | resource |
| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_ec2_transit_gateway.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_transit_gateway) | data source |

## Inputs

Expand Down
35 changes: 30 additions & 5 deletions modules/subnet-group/integrations.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
data "aws_caller_identity" "this" {}

locals {
account_id = data.aws_caller_identity.this.account_id
}


###################################################
# VPC Attachments for Transit Gateway
###################################################

data "aws_ec2_transit_gateway" "this" {
for_each = {
for attachment in var.transit_gateway_attachments :
attachment.name => attachment.transit_gateway
}

filter {
name = "transit-gateway-id"
values = [each.value]
}
}

resource "aws_ec2_transit_gateway_vpc_attachment" "this" {
for_each = {
for attachment in var.transit_gateway_attachments :
Expand All @@ -13,11 +32,17 @@ resource "aws_ec2_transit_gateway_vpc_attachment" "this" {

transit_gateway_id = each.value.transit_gateway

appliance_mode_support = each.value.appliance_mode_enabled ? "enable" : "disable"
dns_support = each.value.dns_support_enabled ? "enable" : "disable"
ipv6_support = each.value.ipv6_enabled ? "enable" : "disable"
transit_gateway_default_route_table_association = each.value.default_association_route_table_enabled
transit_gateway_default_route_table_propagation = each.value.default_propagation_route_table_enabled
appliance_mode_support = each.value.appliance_mode_enabled ? "enable" : "disable"
dns_support = each.value.dns_support_enabled ? "enable" : "disable"
ipv6_support = each.value.ipv6_enabled ? "enable" : "disable"
transit_gateway_default_route_table_association = (local.account_id == data.aws_ec2_transit_gateway.this[each.key].owner_id
? each.value.default_association_route_table_enabled
: null
)
transit_gateway_default_route_table_propagation = (local.account_id == data.aws_ec2_transit_gateway.this[each.key].owner_id
? each.value.default_propagation_route_table_enabled
: null
)

tags = merge(
{
Expand Down

0 comments on commit 8f49de5

Please sign in to comment.