-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ Design Issue ] Allow and prefer reference by id instead of name in all resources #428
Comments
For reference: Issue detected during tests for https://github.com/terraform-providers/terraform-provider-vcd/pull/412#issuecomment-572471499 |
This will also resolve a statement from hashicorp in the documentation about depends_on:
https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies Since the reference by id is a required field, you do not need "depends_on" anymore (see other discussions about dependecies in |
Thank you for a good write-up. Would you update the links to PR to the exact place with relevant comments? As you know, that PR is huge. This will help us get our heads around it when the time comes. |
Adding support by ID is relatively easy. Terraform is already dealing with entities by ID. Removing reference by name, however, is not recommendable, as it makes the system harder to use. I propose adding support for ID-based references, but leaving names in place, as mutually exclusive with IDs, and users will decide which they need to adopt. Note also that the rename problem is a genera issue in all the library entities, and should be resolved, in due time, independently from ID reference. |
Done |
The rename problem is just an example to trigger the issue. If On the other hand: And at least it looks like it is important for you to show a terraform plan that will show clean data about changes, e.g. |
One additional comment: Example: Assume the vApp is not build by terraform, but you want to deploy a VM in it. resource vcd_vapp_vm {
vapp_id = "urn:vapp:12345"
[...]
} But this is not what you do. data vcd_vapp vappdata {
name = "XXX"
}
resource vcd_vapp_vm {
vapp_id = data.vcd_vapp.vappdata.id
[...]
} @dataclouder If you work like this, it may mitigate your assumption that it will be harder to use. |
We are always using IDs now and while there are some legacy places with names, they will gradually be deprecated and removed either with resource EOL, or with a new replacement (like we recently did with |
Affected resources:
Version
Most important example for this issue is vApp and VM resource
In the current design, you reference resources by name.
This has two big issues:
a) Rebuild of a resource will not rebuild the dependency, unless you change the name
b) Changing the name of vApp is possible online, but with this design, it will force rebuild of VM. (see https://github.com/terraform-providers/terraform-provider-vcd/issues/387 as well)
This will lead to an inconsistent terraform plan:
If you change the value of vApp that forces a rebuild of the vApp, terraform plan will only show changes of the vApp. If you run apply, your VM is destroyed, but terraform plan did not reflect this.
Your VM is lost without the possibility for review.
How terraform will detect needed rebuild is explained here:
hashicorp/terraform#8099 (comment)
HCL used to test:
Example for a)
terraform plan if you change vdc only for vApp. If you run apply your VM is deleted without any notice:
Example for b)
Change of name of vApp forces rebuild of VM which is not needed:
Suggested solution:
Add reference by id to each resource, maybe allow use of both, reference by name or id for a while, then deprecate reference by name:
e.g. for vcd_vapp_vm
The text was updated successfully, but these errors were encountered: