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

KMS Module causes Build Pipeline to fail due to unmet dependencies #39

Open
1 task
rutalreja-deloitte opened this issue Mar 9, 2021 · 4 comments
Open
1 task
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work

Comments

@rutalreja-deloitte
Copy link

GCS-CMEK

When the above linked GCS-CMEK is run in the terraform-example-foundation Cloud Build pipeline, it creates Keyrings, Keys, and GCS buckets encrypted with the generated keys in multiple projects parallelly; this produces an error.

Error: googleapi: Error 403: Permission denied on Cloud KMS key. Please ensure that your Cloud Storage service account has been authorized to use this key., forbidden

Causality: The GCS module only requires the key as input, creating the implicit dependency only to the key self-link being available, ignoring the IAM bindings.

As such, Terraform tries to create the GCS bucket before the IAM binding for Role: Encrypter/Decrypter is linked to the KMS Key in many cases, the test even goes further after the failure point and completes the IAM Binding, thus leaving no trace that it was the root cause, if not looking closely at the output. It can only be detected by comparing the line numbers of successfully deployed buckets vs. unsuccessful buckets; in cases where the bucket randomly deploys after the binding has been set, it is successful and fails with the above error when the opposite occurs.

In the linked module, the above was resolved by adding an explicit dependency on the entire KMS module (Only possible in Terraform 0.13+) depends_on = [module.kms]

Suggested Improvement to KMS module until a better solution is ascertained

  • Add Key IAM Binding output variable if someone needs to add a specific binding dependency and not on the entire module. Output Variable
@github-actions
Copy link

github-actions bot commented May 8, 2021

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label May 8, 2021
@morgante morgante added bug Something isn't working P2 high priority issues triaged Scoped and ready for work and removed Stale labels May 17, 2021
@morgante
Copy link
Contributor

I think it would be a good idea to make the outputs in this module dependent on the IAM bindings.

@morgante morgante reopened this May 17, 2021
@bharathkkb
Copy link
Member

@daniel-cit This should let us remove the explicit module level depends on DWH, PTAL

@meons
Copy link

meons commented Apr 3, 2023

Same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work
Projects
None yet
Development

No branches or pull requests

4 participants