-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Some KMS ressources created in the wrong project #4828
Comments
Hi @SkYNewZ, I'm taking a look at the code for the resource/datasource and I don't see anything obviously wrong yet. Can you post debug logs (https://www.terraform.io/docs/internals/debugging.html) for a run that failed? That'll help me see the exact requests/responses that were sent to/from the GCP API. |
I can confirm this. KMS resources are created in the EDIT: the only resource that seems to be looked up in the wrong project is resource "google_project_service" "key_management_system" {
service = "cloudkms.googleapis.com"
disable_on_destroy = false
} |
Project A has a service account to create KMS resources on project B. I found that But currently in KMS resources, To keep homogeneity between resource, I add the project attribute in Terraform resource schem: - has_project = object.base_url.include?('{{project}}')
+ has_project = object.base_url.include?('{{project}}') || object.enable_project_attribute Here is my draft to do that: Creation works with patch:
But the upgrade from existing resource fail because version 1 don't have
|
Cool, that makes sense. I think we can fix this without adding additional fields (either to magic modules itself or to a resource). I'll be able to look at this again next week (maybe as early as Friday of this week), or if you have a PR you'd like reviewed before then, feel free to tag me to review. |
It sounds like there are two separate issues being discussed in this bug, and I want to make sure both of them get resolved. Issue 1 is that certain KMS resources are being created in the project where the service account lives, instead of the one defined in the Terraform config. I can't resolve this issue until I've seen debug logs (https://www.terraform.io/docs/internals/debugging.html) for a failed run. It would help to have the config, plan output, and debug logs together in one gist. Feel free to obfuscate any information you don't feel comfortable sharing publicly, as long as I can tell the difference between the two projects in question. Issue 2 is that the KMS resources / data sources without @SkYNewZ and @JordanP, can you confirm that my explanation of the two issues sounds correct, and if so, post the debug logs in question when you have a chance? |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
Terraform Version
Affected Resource(s)
google_kms_crypto_key
google_kms_secret_ciphertext
Terraform Configuration Files
Expected Behavior
These Terraform files should create a
google_kms_secret_ciphertext
andgoogle_kms_crypto_key
in the givenvar.project_id
.Actual Behavior
google_kms_secret_ciphertext
andgoogle_kms_crypto_key
are created in the service account's project… We will see this with a Terraform error which tell us a wrong project number.We also had this issue on the
google_kms_key_ring
ressource —> fixed withuser_project_override = true
inprovider.tf
. Nevertheless, it's not fixed thegoogle_kms_secret_ciphertext
andgoogle_kms_crypto_key
creation issue.Steps to Reproduce
project_id
invar.project_id
.Important Factoids
Regarding the
terraform-provider-google
orterraform-provider-google-beta
providers generated by https://github.com/GoogleCloudPlatform/magic-modules, we can seeproject
is not used in theses ressources anduser_project_override = true
is not available@jnahelou
The text was updated successfully, but these errors were encountered: