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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where entity values not removed #1054

Merged
merged 4 commits into from
May 19, 2021
Merged

Conversation

jasonodonnell
Copy link
Collaborator

Community Note

  • Please vote on this pull request by adding a 馃憤 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

resource/vault_identity_entity: Fix bug where values are not removed if removed from file

If values are removed from the terraform file, update sees the change but sends no values to Vault. This results in no value changes on the Vault side but Terraform says it succeeded. I've updated the code slightly to use HasChange.

Output from acceptance testing:

$ VAULT_TOKEN=root TF_ACC=true go test -v -run TestAccIdentityEntityUpdate
=== RUN   TestAccIdentityEntityUpdate
vault_identity_entity.entity:
  ID = 880aae6c-8253-d7ed-ca74-1a51cc875126
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 1
  metadata.version = 2
  name = test-entity-495886142902770503-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
vault_identity_entity.entity:
  ID = 880aae6c-8253-d7ed-ca74-1a51cc875126
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 1
  metadata.version = 2
  name = test-entity-495886142902770503-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
vault_identity_entity.entity:
  ID = 880aae6c-8253-d7ed-ca74-1a51cc875126
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 1
  metadata.version = 2
  name = test-entity-495886142902770503-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
vault_identity_entity.entity:
  ID = 880aae6c-8253-d7ed-ca74-1a51cc875126
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 1
  metadata.version = 2
  name = test-entity-495886142902770503-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
vault_identity_entity.entity:
  ID = 880aae6c-8253-d7ed-ca74-1a51cc875126
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 1
  metadata.version = 2
  name = test-entity-495886142902770503-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
--- PASS: TestAccIdentityEntityUpdate (0.17s)
=== RUN   TestAccIdentityEntityUpdateRemoveMetadata
vault_identity_entity.entity:
  ID = 7be2bf99-76df-6e7e-eeb8-e11753448044
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 0
  name = test-entity-6777686168158487119-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
vault_identity_entity.entity:
  ID = 7be2bf99-76df-6e7e-eeb8-e11753448044
  provider = provider.vault
  disabled = false
  external_policies = false
  metadata.% = 0
  name = test-entity-6777686168158487119-2
  policies.# = 2
  policies.1785148924 = test
  policies.326271447 = dev
--- PASS: TestAccIdentityEntityUpdateRemoveMetadata (0.16s)
PASS
ok  	github.com/hashicorp/terraform-provider-vault/vault	0.712s

@ghost ghost added the size/M label May 17, 2021
Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

Seems to work for me!

Left a couple suggestions, but nothing worth holding this up over.

vault/resource_identity_entity_test.go Outdated Show resolved Hide resolved
vault/resource_identity_entity.go Outdated Show resolved Hide resolved
vault/resource_identity_entity_test.go Outdated Show resolved Hide resolved
vault/resource_identity_entity_test.go Outdated Show resolved Hide resolved
vault/resource_identity_entity_test.go Show resolved Hide resolved
@jasonodonnell jasonodonnell merged commit 4b53f6d into master May 19, 2021
@jasonodonnell jasonodonnell deleted the entity-meta-bug branch May 19, 2021 13:54
davidmontoyago pushed a commit to davidmontoyago/terraform-provider-vault that referenced this pull request Aug 17, 2021
* Fix bug where entity values not removed

* Add more values to test

* Fix edge case with external policies

* Add review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants