-
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
Error: key "ssh-keys" already present in metadata for project in GCP #6440
Comments
@vikas4cloud This is expected behavior, If you have already created the metadata using other methods, Terraform does not have knowledge about it, and then will not overwrite it. That is why you have to create the state by calling |
@edwardmedia Thanks for your message let assume its a expected behavior of terraform then how to add more keys as well as i have added the 2 keys (first time) with terraform only scenario 1 if i want to add another 2 keys how can i add keys ?? scenario 2 - if i am adding 2 new keys via terraform script its replacing old keys and adding only new 2 keys working scenario 3 if i will keep all previous keys and appending the 2 more new keys then its adding but keeping all keys for adding new key is not a good practice for me. can u let is know if this is a expected behiver than how can we achieve (adding more keys) we would not like to use import as our jenkins jobs have same mechanism(init-plan-apply) for Iac |
@vikas4cloud you may use below way or Terraform dynamic blocks feature to create multiple keys. Keep in mind, if you have already had keys that were created through non-Terraform methods, you have to run resource "google_compute_project_metadata_item" "item1" {
key = "key1"
value = "value1"
}
resource "google_compute_project_metadata_item" "item2" {
key = "key2"
value = "value2"
} |
@vikas4cloud I am closing this issue at this moment. Please feel free to reopen it if you still have related questions |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v0.12.24
Affected Resource(s)
Terraform v0.12.24
Terraform Configuration Files
Debug Output
Panic Output
Error: key "ssh-keys" already present in metadata for project
google_compute_project_metadata_item.username: Creating...
Error: key "ssh-keys" already present in metadata for project "solid-ridge-266407". Use
terraform import
to manage it with Terraformon main.tf line 1, in resource "google_compute_project_metadata_item" "username":
1: resource "google_compute_project_metadata_item" "username" {
Expected Behavior
Expecting to add the provided key to the metadata/sshKeys
https://console.cloud.google.com/compute/metadata/sshKeys
Actual Behavior
its replacing the previous sshKeys its not appending
it should append as well as should not delete the previous terraform apply
Steps to Reproduce
add users key in terraform.tfvars file
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: