Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Oct 14, 2022
1 parent 3b61919 commit 6b9f489
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions vpc-transit-gateway-association/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This sets up the necessary transit gateway configuration for attaching a VPC wit
| <a name="provider_aws.network_account"></a> [aws.network\_account](#provider\_aws.network\_account) | >= 3.66.0 |
| <a name="provider_aws.peer"></a> [aws.peer](#provider\_aws.peer) | >= 3.66.0 |
| <a name="provider_aws.self"></a> [aws.self](#provider\_aws.self) | >= 3.66.0 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.0 |

## Modules

Expand All @@ -50,6 +51,7 @@ This sets up the necessary transit gateway configuration for attaching a VPC wit
| [aws_ec2_transit_gateway_route_table_propagation.vpc_self_own_rt](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_route_table_propagation) | resource |
| [aws_ec2_transit_gateway_vpc_attachment.vpc_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway_vpc_attachment) | resource |
| [aws_route.gateway_ipv4](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [null_resource.vpc_attachment_exists](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source |
| [aws_arn.network_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source |
| [aws_availability_zone.zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
Expand Down
9 changes: 8 additions & 1 deletion vpc-transit-gateway-association/routing.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ data "aws_ec2_managed_prefix_list" "tgw_ipv4" {
id = each.key
}

resource "null_resource" "vpc_attachment_exists" {
triggers = {
vpc_attachment = one(aws_ec2_transit_gateway_vpc_attachment.vpc_attachment[*].id)
}
}


# pick the first prefix list found, either NAME or NAME.ipv4
resource "aws_route" "gateway_ipv4" {
for_each = var.transit_gateway_routing_type == "self" ? module.routing_attachment_ipv4[0].private_route_table_ids : {}
Expand All @@ -46,5 +53,5 @@ resource "aws_route" "gateway_ipv4" {
destination_prefix_list_id = one([for k, v in data.aws_ec2_managed_prefix_list.tgw_ipv4 : k if v.address_family == "IPv4"])
transit_gateway_id = data.aws_ec2_transit_gateway.gateway_self.id

depends_on = [aws_ec2_transit_gateway_vpc_attachment.vpc_attachment]
depends_on = [null_resource.vpc_attachment_exists]
}

0 comments on commit 6b9f489

Please sign in to comment.