Terraform overrides constructed ID
- Dominant language
- Go
- Stars
- 481
- Forks
- 131
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 11
Description
In provider-gcp for many resources there are more than one possible import statements:
```
$ terraform import google_compute_resource_policy.default projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}
$ terraform import google_compute_resource_policy.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_resource_policy.default {{region}}/{{name}}
$ terraform import google_compute_resource_policy.default {{name}}
```
Now, for external name configuration, we choose the longest one (in the first order) and use this string for constructing Terraform ID.
In the previous days, we discuss that using the shortest one (in the last order). So we tried to use the NameAsIdentifier configuration choice.
During this test we observed that the Terraform ID was overridden after Terraform call.
In first loop, we construct the ID by using only external name: `example` and write to the `terraform.tfstate`. After Terraform calls, Terraform overrides the ID in the `terraform.tfstate` and sets to the longest one: `projects/official-provider-testing/regions/us-central/resourcePolicies/example`.
So, I opened this issue to discuss the possible impacts of this behavior.
Contributor guide
Assessment
This issue has not been assessed yet.