Introduction
Customers can choose to create HVN and TGW attachments using Terraform Provider. For additional details, check Terraform Provider (hcp_aws_transit_gateway_attachment (Resource).
Problem
When trying to create resources such as HVN and TGW attachments, using Terraform Provider, the following error appears:
Error: unable to check for presence of an existing transit gateway attachment (example-tgw-attachment): [GET /network/2020-09-07/organizations/{hvn.location.organizationid}/projects/{hvn.location.projectid}/networks/{hvn.id}/transit-gateway-attachments/{id}][500] GetTGWAttachment default &{Code:13 Details:[] Error: Message:}
│
│ with hcpawstransitgatewayattachment.example,
│ on main.tf line 51, in resource "hcpawstransitgatewayattachment" "example":
│ 51: resource "hcpawstransitgatewayattachment" "example" {
Cause
The error appears due to using the same project_id
& transit_gateway_attachment_id
in the Terraform Plan for the subsequent creation of resources under the same HCP Project, since the TGW attachment ID is being created in the below format:
"id": "/project/<PROJECT_ID>/hashicorp.network.tgw-attachment/<transit_gateway_attachment_id>",
Solution
There are a couple of solutions, which are outlined below:
1. Change the TGW attachment ID (transit_gateway_attachment_id) to not overlap with an existing one in the project.
2. Deploy resources in a different HCP Project altogether. When choosing this option, it's not necessary to change the attachment_id as mentioned in the solution above.