-
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
Running the plan with google_compute_instance_template results in an error #2067
Comments
This also applies to my configurations with a custom image. I tried to get a self_link using data.google_compute_image (which actually resolves it correctly), but i´m still getting the error as mentioned. |
also happens with: resource "google_compute_instance_template" "foo_1" {
machine_type = "n1-standard-2"
region = "${var.gcp_region}"
tags = ["${var.gcp_network_private_tag}", "fooo"]
can_ip_forward = false
disk {
source_image = "ubuntu-os-cloud/ubuntu-1404-lts"
disk_size_gb = "60"
auto_delete = true
boot = true
}
disk {
auto_delete = true
boot = false
disk_size_gb = "100"
disk_type = "pd-ssd"
}
metadata {
block-project-ssh-keys = false
}
network_interface {
subnetwork = "${google_compute_subnetwork.subnet_private.name}"
}
lifecycle {
create_before_destroy = true
}
} |
I ran into this issue and found a resolution. Two prong approach
These two combinations allowed me to resolve my initial error of flattening disks and allowed my I think I got into this erroneous state by being allowed to create my instance templates using Fix: disallow source_image to take a string? |
Fix Dana's comments, one of which exposed a bug: we weren't actually fixing the diff. Because resolveImage can return multiple formats, and only returns a self_link if a self_link is passed in, it was diffing more often than not against a self_link supplied in the config. We just had a bug in our CustomizeDiff function that concealed this. I added the resolvedImageSelfLink helper function to turn the output from resolveImage into a self_link, which fixes the problem. It also has the knock-on effect of fixing #2067 at the same time, which is nice. I decided to add another function instead of just modifying resolveImage to always return a self_link because I don't want to deal with the backwards compatibility problems of changing how we're storing a bunch of things in state this close to 1.19.0. And honestly, we should probably just be storing the self_link always, _anyways_.
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_compute_instance_template
Terraform Configuration Files
Expected Behavior
I did not change it.
Actual Behavior
terraform plan
Important Factoids
The image specified by source_image is an image of an image created by another project.
It is not an image existing by default in GCP.
Also, this google_compute_instance_template is a resource you have already created.
References
This correction seems to have caused this problem.
The text was updated successfully, but these errors were encountered: