You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When managing secrets, if terraform attempts to set a value for a secret that exists, but has an empty value (for example, when creating a resource for a new environment in an existing project), having a nil value for that secret leads the terraform provider to believe it doesn't have access to retrieve it, rather than correctly realizing the secret simply has an empty value.
Reproduction:
Create a new environment in an existing project.
Create a secret in an existing environment via terraform.
Change the secret to point to the new project instead (note that when I did this, I had separate tokens for each of the two projects, with separate terraform configs).
Run terraform apply.
Example of the error:
╷
│ Error: One or more secret fields are restricted: [raw computed]. You must use a service account or service token to manage these resources. Otherwise, Terraform cannot fetch these restricted secrets to check the validity of their state.
│
│ with doppler_secret.cnpg_backup_key_bitty,
│ on b2_bitty_cnpg_backup_bucket.tf line 12, in resource "doppler_secret" "cnpg_backup_key_bitty":
│ 12: resource "doppler_secret" "cnpg_backup_key_bitty" {
│
╵
Remediations attempted:
Using a personal token
Upgrading to teams and using a service account
Successful remediation:
To fix this broken state, I had to set a bogus password value "asdf" through the UI, and then re-run terraform apply.
Thanks for reporting this, @rtrox and I appreciate the detail! It looks like we're missing ForceNew flags for the doppler_secret resource. A doppler_secret can't be moved from one project or config to another, it must be deleted and recreated. We use null values in the fetch secrets API to indicate that a secret's value is restricted but we should never have attempted to fetch the secret if it doesn't exist.
When managing secrets, if terraform attempts to set a value for a secret that exists, but has an empty value (for example, when creating a resource for a new environment in an existing project), having a nil value for that secret leads the terraform provider to believe it doesn't have access to retrieve it, rather than correctly realizing the secret simply has an empty value.
Reproduction:
Example of the error:
Remediations attempted:
Successful remediation:
To fix this broken state, I had to set a bogus password value "asdf" through the UI, and then re-run terraform apply.
Provider Configs:
relevant secret entry:
This is the relevant code, it seems to naively assume that a nil value means it doesn't have access:
terraform-provider-doppler/doppler/resource_secret.go
Lines 119 to 132 in 2407bf2
The text was updated successfully, but these errors were encountered: