ionos-cloud / terraform-provider-ionoscloud

The IonosCloud Terraform provider gives the ability to deploy and configure resources using the IonosCloud APIs.
Mozilla Public License 2.0
35 stars 24 forks source link

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

Closed Ntr0 closed 2 years ago

Ntr0 commented 2 years ago

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 2 years ago

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

MarcThe commented 2 years ago

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?

cristiGuranIonos commented 2 years ago

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.

MarcThe commented 2 years ago

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, ...).