ionos-cloud/terraform-provider-ionoscloud

Using cloud-init volumes is not idempotent: Error: volume.0.user_data attribute is immutable

Ntr0 opened this issue · 4 comments

Ntr0 commented

Description

Adding a server with specified user-data will make it impossible run terraform apply more than once. To do so, following lifecycle paradigm must be added:

  lifecycle {
    ignore_changes = [ volume.0.user_data ]
  }

Expected behavior

At least terraform should not break, if user data is used, so at least, the fact that user data is not returned from the cloud api, should lead to ignoring this field, when state is refreshed.

Environment

Terraform version:

Terraform v0.15.4

Provider version:

+ provider registry.terraform.io/hashicorp/local v2.2.2
+ provider registry.terraform.io/hashicorp/tls v3.3.0
+ provider registry.terraform.io/ionos-cloud/ionoscloud v6.2.3

OS:

on linux_amd64

Configuration Files

How to Reproduce

Error and Debug Output

Additional Notes

References

Ntr0 commented

Nevermind, was using a complete outdated terraform version. /close

Im having the same problem on:

Terraform v1.2.9
on linux_amd64
+ provider registry.terraform.io/ionos-cloud/ionoscloud v6.3.2

When trying to plan or apply onto a created 'ionosccloud_server' resource I cant can't run plan or apply:
Error: volume.0.user_data attribute is immutable, therefore not allowed in update requests

Anyone got a fix to this?

User_data can only be set on server creation. You need to first destroy the server, change user_data and then run apply. The other option would be for us to change user_data so that it forces server re-creation on update.

I believe re-creation would be the Terraform native approach.
The problem with the current setup is that it blocks most Terraform actions(plan, apply, plan -replace, plan -destroy, ...).