Hi
I am using terraform(aws provider 5.8.0) to create and associate a route table to a direct connect gateway TGW association. The terraform resource block for “aws_ec2_transit_gateway_route_table_association” requires a “transit_gateway_attachment_id”. How do I reference to the TGW attachment to direct connect gateway in this case? I can’t seem to find any attribute for “aws_dx_gateway_association” resource that provides a “transit_gateway_attachment_id”.
Below is a sample code I am using. The last resource block for “aws_ec2_transit_gateway_route_table_association” is where I am having trouble finding a way to reference to the TGW attachment to the direct connect gateway.
resource “aws_dx_gateway_association” “dxg-to-tgw-assoc”{
dx_gateway_id = some dxg id
associated_gateway_id = some tgw id
allowed_prefixes = [
“E.F.G.H/24”
]
}
#Create route table
resource “aws_ec2_transit_gateway_route_table” “rt-A” {
transit_gateway_id = aws_ec2_transit_gateway.tgw-dx-opsnet.id
}
#Create routes
resource “aws_ec2_transit_gateway_route” “some-routes” {
destination_cidr_block = “A.B.C.D/24”
transit_gateway_attachment_id = some vpc attachment id
transit_gateway_route_table_id = aws_ec2_transit_gateway_route_table.rt-A.id
}
#Associate route table to TGW attachments
#Associate to DXGW association
resource “aws_ec2_transit_gateway_route_table_association” “assoc-rt-A-to-dxg-attachment” {
transit_gateway_attachment_id = <how do I reference to the dxg transit gw association?>
transit_gateway_route_table_id = aws_ec2_transit_gateway_route_table.rt-A.id
}
Thank you.