Closed MAYUR3598 closed 1 year ago
Hi,
Could you confirm the TGW attachment in question is in an "available" state ?
aws2tf ignores attachments that are not "available" because the resource being attached to the TGW is likely to have been deleted and so the attachment is no longer intended/valid.
Hi,
I've verified twice and attachments shows in available state.
Thanks for checking.
Are these attachments to resources within the same AWS account - or another AWS account ?
Have a possible fix in the pipeline - although it's wrapped up in other v4.xx testing, as there's quite a lot changed with the latest aws provider version.
Hi,
1 attachment is from same account and another one is from same account but different region.
Also would like to get aws_route_table but it seems to very few resources defined in aws2tf.sh file, i can see the files in scripts but not sure how can we proceed?
The cumulative mode will help you (-c yes)
You could start with ./aws2tf.sh -t tgw
Then for subsequent runs include "-c yes" as you import more resource types, eg to get a VPC & it's subnets, route tables etc...
./aws2tf.sh -c yes -t vpc -i vpc-xxxxxxxxxxx
or the other way around if that makes more sense - vpc first and tgw in cumulative mode
Crossing regions will require manual copying and merging of Terraform resources - as this tool currently uses a separate directory in the generated sub directory for each account-region combination.
It is possible to call the individual script files one at a time (having done an initial aws2tf.sh run.)
$ cd generated/tf.0123456789012/_region $ export AWS=aws
Then call then individually
../../scripts/107-get-route-table.sh vpc-xxxxxxxxxxx
It's not intended to be used this way - but I do it for testing/debugging.
changes included - let me know if it fixes your issue
Hi,
It's still giving me an error.
Error: Reference to undeclared resource
on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-06b62799c8aa0b843.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-06b62799c8aa0b843" has not been declared in the root module. type-get-transitgw.sh runtime 153 seconds Total runtime in seconds 153 Wed 4 May 2022 12:16:06 IST terraform fmt > /dev/null ...
Error: Reference to undeclared resource
on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-06b62799c8aa0b843.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-06b62799c8aa0b843" has not been declared in the root module. fix default SG's Terraform validate ...
Error: Reference to undeclared resource
on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-06b62799c8aa0b843.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-06b62799c8aa0b843" has not been declared in the root module.
Is this attachment the one related to the other region ?
Yes that is from another region and resource type is Peering.
Committed fixes that should now fix this. Although it is difficult to check/test every case. Just open a new issue if you continue to see problems
Hi Team,
getting below error while importing tgw resources following below command: ./aws2tf.sh -v yes -t tgw
Logs: on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-0775386e6f5a52a99.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-0775386e6f5a52a99" has not been declared in the root module. fix default SG's Terraform validate ...
Error: Reference to undeclared resource
on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-06b62799c8aa0b843.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-06b62799c8aa0b843" has not been declared in the root module.
Error: Reference to undeclared resource
on aws_ec2_transit_gateway_route__tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16.tf line 6, in resource "aws_ec2_transit_gateway_route" "tgw-rtb-0f65b6e20bfd4083b_10_0_0_0_16": 6: transit_gateway_attachment_id = aws_ec2_transit_gateway_vpc_attachment.tgw-attach-0775386e6f5a52a99.id
A managed resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-attach-0775386e6f5a52a99" has not been declared in the root module.