Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace secret store on id change #102

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

mateuszjenek
Copy link
Contributor

This PR resolves an issue preventing updates to the id of the secret store. Previously, providers attempted to modify the id field directly, which the API does not permit. The new behavior replaces the entire resource instead.

Example output:

$terraform apply
humanitec_secretstore.ss: Refreshing state... [id=saml-test-ss-1]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # humanitec_secretstore.ss must be replaced
-/+ resource "humanitec_secretstore" "ss" {
      ~ id      = "saml-test-ss-1" -> "saml-test-ss-2" # forces replacement
        # (2 unchanged attributes hidden)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

humanitec_secretstore.ss: Destroying... [id=saml-test-ss-1]
humanitec_secretstore.ss: Destruction complete after 0s
humanitec_secretstore.ss: Creating...
humanitec_secretstore.ss: Creation complete after 0s [id=saml-test-ss-2]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

@@ -92,6 +94,9 @@ func (*SecretStore) Schema(ctx context.Context, req resource.SchemaRequest, resp
"id": schema.StringAttribute{
MarkdownDescription: "The ID of the Secret Store.",
Required: true,
PlanModifiers: []planmodifier.String{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some integration tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a modifier test per se, but I've added a test that changes the id and verifies that the new resource reflects the updated id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'd like to see if a proof that the old secret store has been deleted and the new one has the new id. The 1st check might require a Humanitec client to fetch api.

@mateuszjenek mateuszjenek merged commit 54dca55 into main Oct 25, 2024
2 checks passed
@mateuszjenek mateuszjenek deleted the replace_secret_store_on_id_change branch October 25, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants