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

Add RequiresReplace attribute for secret_name in hvs secret resource #1157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

divyapola5
Copy link
Contributor

🛠️ Description

If you change the name of a hcp_vault_secrets_secret it is expected that the secret with the previous name gets deleted and the a secret with the new name gets created. However, the TF provider treats it as an update and creates the new secret while not deleting the previous one. This change adds a fix for this.

JIRA: https://hashicorp.atlassian.net/browse/HV-3235

🏗️ Acceptance tests

  • Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Local test where I changed the app name and secret name, terraform plan shows 2 to be added and 2 to be destroyed
Screenshot 2024-12-18 at 2 07 17 PM

@divyapola5 divyapola5 requested a review from a team as a code owner December 18, 2024 20:12
@divyapola5 divyapola5 requested review from a team as code owners December 18, 2024 20:16
@@ -76,6 +76,9 @@ func (r *resourceVaultsecretsSecret) Schema(_ context.Context, _ resource.Schema
"must contain only ASCII letters, numbers, and underscores; must not start with a number",
),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Copy link
Contributor

@maxcoulombe maxcoulombe Dec 18, 2024

Choose a reason for hiding this comment

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

We should add this to the app_name since it is not a modifiable field either.

Can we add tests for that scenario? Something like a CheckDestroy that verifies the secret with the old name no longer exists after the rename is applied. A good rule of thumb is 1 regression = 1 new test!

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.

2 participants