Closed envy closed 3 years ago
@envy, thanks for reporting the issue. Actually, I think the issue presents since we update our Ubuntu 20.04 template. The update happened on our backend and caused the change of the Ubuntu 20.04 template UUID. To prevent this, you'd better use ignore_changes
resource "gridscale_storage" "this" {
name = "somename"
capacity = 20
storage_type = "storage"
template {
template_uuid = data.gridscale_template.ubuntu2004.id
sshkeys = [
var.sshkey
]
}
lifecycle {
ignore_changes = [
template.0.template_uuid,
]
}
}
@bkircher what do you think?
Thanks! Will do that in the future.
Still, I think the provider should default to that behavior for the template when the storage already exists.
Thanks! Will do that in the future.
Still, I think the provider should default to that behavior for the template when the storage already exists.
Actually this behavior is expected in terraform since the UUID of the template is changed. I think this issue should be solved in our backend side, as a change in name of the template should not cause the change in template UUID. Anyway, we will look into this issue.
Hey there,
We changed template UUIDs for CentOS 8 and Ubuntu 20.04 when we updated those templates earlier this week. This shouldn't have happened and we learned to not do that in the future for existing OS templates we publish on my.gridscale.io and partner sites.
That one is on me. Sorry, if that caused any trouble!
data "gridscale_template" "ubuntu2004" {
name = "Ubuntu 20.04 LTS (Focal Fossa)"
}
Totally legit. I would use the template UUID as a reference since I can promise from now on that we don't change UUIDs anymore. (Names however might change. Not necessarily often, though.)
The use of the lifecycle
ignore_changes
meta-argument is really helpful here to have TF set the value when the data or resource is first created and ignore any subsequent change to it in any terraform apply
that follows. Even if we remove OS templates because they become EOL.
I think we should incorporate such strategies in our TF examples.
@envy FYI, OS templates have been reverted to their old UUIDs and names. In case for Ubuntu 20.04 this would be Ubuntu 20.04 LTS (Focal Fossa)
and fd65f8ce-e2c6-40af-8fc3-92efa0d4eecb
.
Issue is resolved
We have been using the terraform provider for some months now but noticed today that it errors with:
Error: read template (Ubuntu 20.04 LTS (Focal Fossa)) datasource - error: Template Ubuntu 20.04 LTS (Focal Fossa) not found
Alright, seems like you renamend your template to
Ubuntu 20.04
. So I changed it in my config.And now TF wants to replace all my storages using that template because apparently the template UUID changed.
This is a provider issue in my eyes, because:
After the storage has been created, the reference to the template should be irrelevant as the storage will not match the template anyway afterwards, so why is it relevant and kept around?
The only solution I saw was to replace the old template UUID with the new one in my state by changing the state JSON by hand so that it thinks all storages were created with the new template.
Terraform Version
Doesn't matter
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Expected Behavior
Changing the template should not affect existing storages. They already diverted from the template the first time they booted.
Actual Behavior
TF wanted to replace all storages whose template changed.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform plan
will now show you that it wants to replace the storage because the template has changed.