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
The zonal field for resource disks cannot be empty #658
Comments
0.10.8 yields same result. |
Hey @allandrick, you definitely shouldn't need the empty initialize_params block. Can you show me what your previous config looked like, as well as the output of |
Hi @danawillow - yeah, the empty initialize_params block was a definite work-around. Previous config looked like (sanitised): resource "google_compute_disk" "os-disk" {
name = "os-disk"
type = "pd-standard"
zone = "us-east1-b"
size = "100"
image = "windows-2012-r2"
lifecycle {
prevent_destroy = "true"
}
}
resource "google_compute_disk" "data-disk" {
name = "data-disk"
type = "pd-standard"
zone = "us-east1-b"
size = "500"
lifecycle {
prevent_destroy = "true"
}
}
resource "google_compute_instance" "server" {
name = "server"
description = "Server"
machine_type = "n1-standard-2"
zone = "us-east1-b"
lifecycle {
ignore_changes = [
"create_timeout"
]
}
disk {
disk = "os-disk"
device_name = "disk1"
auto_delete = "false"
}
... the terraform plan before changes:
so I change: disk {
disk = "disk-name"
device_name = "disk1"
auto_delete = "false" to: boot_disk {
source = "${google_compute_disk.disk-name.self_link}"
device_name = "disk1"
auto_delete = "false" and similarly any second disks from: disk {
name = "data"
device_name = "disk2"
auto_delete = "false"
} to attached_disk {
source = "${google_compute_disk.data.self_link}"
device_name = "disk2"
} Then terraform plan says: -/+ google_compute_instance.server (new resource required)
id: "server" => <computed> (forces new resource)
boot_disk.#: "1" => "1"
boot_disk.0.auto_delete: "false" => "false"
boot_disk.0.device_name: "disk1" => "disk1"
boot_disk.0.disk_encryption_key_sha256: "" => <computed>
boot_disk.0.initialize_params.#: "1" => "0" (forces new resource)
... with no other changes identified. |
@danawillow FWIW, this has worked in several other projects - it's just one project where now it is unable to refresh due to this zonal resource disk issue - I don't think it is related to the initialize_params (we should probably split those two issues out). |
Hey @allandrick, with the config I'm seeing now I can't reproduce that exact error. I actually get a different one- I can send out a fix for the migration that put |
@danawillow thanks for the chat - confirming for anyone else having this issue, the problem was (for some reason, probably my fat fingers) that the state had an invalid number of elements in the attached disks array on the google_compute_instance resource (there was supposed to be 1 attached disk and 1 boot disk): "attributes": {
"attached_disk.#": "2",
"attached_disk.1.device_name": "data-disk",
"attached_disk.1.disk_encryption_key_raw": "",
"attached_disk.1.disk_encryption_key_sha256": "",
"attached_disk.1.source": "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-east1-b/disks/data-disk", instead of "attributes": {
"attached_disk.#": "1",
"attached_disk.0.device_name": "data-disk",
"attached_disk.0.disk_encryption_key_raw": "",
"attached_disk.0.disk_encryption_key_sha256": "",
"attached_disk.0.source": "https://www.googleapis.com/compute/v1/projects/project-id/zones/us-east1-b/disks/data-disk", Thanks again for the second set of eyes! Regards, Leigh |
Signed-off-by: Modular Magician <magic-modules@google.com>
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! |
Hi there,
I'm upgrading a project from 0.8.2 to 0.10.7 and having problems with an existing google_compute_instance resource and its associated disk(s).
I became aware that previous references to disks using the
method to link in an existing google_compute_disk resource needed to be changed to:
and this has worked for several VMs across different projects coming from various terraform versions up to and including 0.10.7. The initialize_params shouldn't have needed to be there, especially given the presence of the source parameter, but terraform plan kept saying it wanted to force new resource on the instance because initialize_params went from 1 => 0 - this work-around was the closest I could get to a clean "no change moving forward" plan.
However, in one particularly old project, I am now getting a strange error on terraform refresh:
with no other additional info.
Terraform Version
Terraform v0.10.7
The release notes for 0.10.8 do not indicate any related fixes to this issue and this appears to be a Google provider specific error message.
Affected Resource(s)
Terraform Configuration Files
Debug Output
Debug output can be provided on request.
Panic Output
no panic output.
Expected Behavior
refresh and plan
Actual Behavior
error above.
Steps to Reproduce
terraform refresh
Important Factoids
nothing out of the ordinary!
References
none
The text was updated successfully, but these errors were encountered: