Aws_dx_gateway_association / output property seems to be malformed?

Hi everyone :grinning:

I try to build IaC workflow to create global Network layer for AWS Multi Accounts customer.

I have a big problem with the aws_dx_gateway_association resource.

This is an example :

#Creates Direct Connect Gateway
resource "aws_dx_gateway" "this" {
  name            = "mydxgateway"
  amazon_side_asn = 64514

#Creates Direct Connect Gateway association with Transit Gateway
resource "aws_dx_gateway_association" "this" {
  dx_gateway_id         =
  associated_gateway_id = "tgw-rtb-05bbb377acb7ecf46"

  allowed_prefixes = [""]

Now I try to retreive this association id like this :

resource "aws_ec2_transit_gateway_route_table_association" "dx" {
   transit_gateway_route_table_id = "tgw-rtb-05bbb377acb7ecf46"
   transit_gateway_attachment_id  = aws_dx_gateway_association.this.dx_gateway_association_id

I have got an error during “apply” execution :

Error: error associating EC2 Transit Gateway Route Table (tgw-rtb-05bbb377acb7ecf46) association (f3454ce1-4387-42e9-986a-b762f46f3c90): InvalidTransitGatewayAttachmentID.Malformed: Invalid Transit Gateway Attachment id f3454ce1-4387-42e9-986a-b762f46f3c90.
status code: 400, request id: 05560c5c-86f1-4951-b71f-e27bf4979169

If I take a look at the plan… indeed… the property seems to be malformed :

“associated_gateway_id”: “tgw-0f61e6aa07906bf7c”,
“associated_gateway_owner_account_id”: “XXXXXXXXXX”,
“associated_gateway_type”: “transitGateway”,
“dx_gateway_association_id”: “f3454ce1-4387-42e9-986a-b762f46f3c90”,
“dx_gateway_id”: “8a44646d-336c-4621-b032-d9a83252ce0e”,
“dx_gateway_owner_account_id”: “XXXXXXXXXX”,
“id”: “ga-8a44646d-336c-4621-b032-d9a83252ce0etgw-0f61e6aa07906bf7c”,

But if I look on AWS Console, the correct attachment id == “tgw-attach-05770a0a1186d57d3”.

Any idea ?

Thanks a lot.

Thanks to Slav Donchev (Support) for his answer.

For information, the real attachment id can be retreived using :

data "aws_ec2_transit_gateway_dx_gateway_attachment" "this" {
  transit_gateway_id = "The Transit Gateway ID"
  dx_gateway_id        = "The Direct Connect Gateway ID"

Now I can continue my global network topology :smiley: