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

Remove use of google_kms_crypto_key_iam_binding resources in acceptance tests to reduce test failures related to missing permissions #6737

Conversation

modular-magician
Copy link
Collaborator

Related to hashicorp/terraform-provider-google#16687

We have a group of bootstrapped KMS keys in the test projects that can be used by acceptance tests but aren't created/deleted by tests.

Because these resources are reused by tests there is a chance that tests will conflict with each other when editing the IAM permissions on the resource.

In this PR I remove unnecessary use of google_kms_crypto_key_iam_binding so it's easier to identify instances when a test is affecting bootstrapped resources' IAM policies authoritatively.

An example I've identified that affects a bootstrapped KMS key is generated from the mmv1/templates/terraform/examples/cloudfunctions2_cmek.tf.erb file to make the generated test TestAccCloudfunctions2function_cloudfunctions2CmekExample

Release Note Template for Downstream PRs (will be copied)


Derived from GoogleCloudPlatform/magic-modules#9590

…ance tests to reduce test failures related to missing permissions (#9590)

* Replace use of `google_kms_crypto_key_iam_binding` with `_member` equivalent

* Replace use of `google_kms_crypto_key_iam_binding` with `_member` equivalent in examples files

* Split `google_kms_crypto_key_iam_binding` with 2 members into two `_member` IAM resources in example file

* Replace `google_kms_crypto_key_iam_binding` with 5 members into `_member` IAM resources created via for_each loop

When this example is used to generate a test the crypto key used is a bootstrapped resource. By using an authoritative `_binding` IAM resource we allow conflict between tests using the same bootstrapped cypto key

* Fix mistyped argument name

* Remove use of for_each in acceptance test, create separate example files for test vs docs

* SKip `TestAccCloudfunctions2function_cloudfunctions2CmekExample` in VCR

* Skip `TestAccDataprocMetastoreService_dataprocMetastoreServiceCmekTestExample` in VCR
[upstream:9e772a85d6c113ae38b6e5439d7ae72380481bec]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit 6d65f34 into hashicorp:main Dec 11, 2023
2 checks passed
@modular-magician modular-magician deleted the downstream-pr-9e772a85d6c113ae38b6e5439d7ae72380481bec branch November 16, 2024 03:56
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.

1 participant