rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 216 forks source link

[BUG] Provider crash on changing rancher2_custom_user_token's password #1354

Open mouellet opened 1 month ago

mouellet commented 1 month ago

Rancher Server Setup

Information about the Cluster

User Information

N/D

Provider Information

Describe the bug

Changing the 'password' attribute of the rancher2_custom_user_token resource doesn't recreate it as documented.

https://github.com/rancher/terraform-provider-rancher2/blob/master/docs/resources/custom_user_token.md?plain=1#L15

Tokens can't be updated once created. Any diff in token data will recreate the token. If any token expire, Rancher2 provider will generate a diff to regenerate it.

https://github.com/rancher/terraform-provider-rancher2/blob/master/docs/resources/custom_user_token.md?plain=1#L51

password - (Required/ForceNew) The user password (string)

To Reproduce

  1. create a rancher2_custom_user_token resource
  2. change the password attribute

Actual Result

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to
│ rancher2_custom_user_token.this,
│ provider "provider[\"registry.terraform.io/rancher/rancher2\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

Expected Result

Resource should be recreated

Screenshots

Additional context

Schema is missing a ForceNew: true, here: https://github.com/rancher/terraform-provider-rancher2/blob/master/rancher2/schema_custom_user_token.go#L11-L16

matttrach commented 3 weeks ago

Thank you so much! I agree with your assessment, I will work on making this change for our next release.