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

google_compute_disk created from snapshot, forces new resource then apply once more #218

Closed
z1nkum opened this issue Jul 19, 2017 · 6 comments
Labels

Comments

@z1nkum
Copy link

z1nkum commented Jul 19, 2017

Looks like google_compute_disk was broken since v0.9.6 (or v0.9.7)

Create disk snapshot and then disk from this snapshot (clone disk operation)
If we execute terraform apply once more newly created disk will be destroyed and recreated

Terraform Version

Terraform v0.9.11

Affected Resource(s)

google_compute_disk

Terraform Configuration Files

resource "google_compute_snapshot" "db-shard1-4-root-snapshot" {
  name  = "db-shard1-4-root-snapshot"
  source_disk  = "db-shard1-4"
  zone  = "${google_compute_instance.db-shard1-4.zone}"
}

resource "google_compute_disk" "db-shard1-4-root-disk-from-snapshot" {
  name  = "db-shard1-4-root-cloned-disk-${count.index + 1}"
  type  = "pd-standard"
  zone  = "${var.zone-chooser[count.index]}"
  snapshot = "${google_compute_snapshot.db-shard1-4-root-snapshot.name}"
  count = 1
}

Debug Output

-/+ google_compute_disk.db-shard1-4-root-disk-from-snapshot
    disk_encryption_key_sha256: "" => "<computed>"
    name:                       "db-shard1-4-root-cloned-disk-1" => "db-shard1-4-root-cloned-disk-1"
    self_link:                  "https://www.googleapis.com/compute/v1/projects/projectnamehere/zones/us-east1-d/disks/db-shard1-4-root-cloned-disk-1" => "<computed>"
    size:                       "10" => "0"
    snapshot:                   "https://www.googleapis.com/compute/v1/projects/projectnamehere/global/snapshots/db-shard1-4-root-snapshot" => "db-shard1-4-root-snapshot" (forces new resource)
    type:                       "pd-standard" => "pd-standard"
    users.#:                    "0" => "<computed>"
    zone:                       "us-east1-d" => "us-east1-d"


Plan: 1 to add, 0 to change, 1 to destroy.

Expected Behavior

No changes expected on 2nd and others "terraform apply"

Actual Behavior

Terraform decide to recreate disks (why??)

Steps to Reproduce

List the steps required to reproduce the issue:
Execute terraform apply
And once more: terraform apply

z1nkum pushed a commit to z1nkum/terraform-provider-google that referenced this issue Jul 25, 2017
@grubernaut grubernaut added the bug label Jul 26, 2017
@nodesocket
Copy link
Contributor

nodesocket commented Aug 3, 2017

Maybe I spoke too soon. This seems to actually still be a bug.

iMac ➜  terraform git:(master) ✗ terraform apply
Error applying plan:

1 error(s) occurred:

* google_compute_disk.blog (destroy): 1 error(s) occurred:

* google_compute_disk.blog: Error detaching disk persistent-disk-0 from instance my-project/https://www.googleapis.com/compute/v1/projects/my-project/zones/us-west1-a/blog: googleapi: Error 400: Invalid value 'https://www.googleapis.com/compute/v1/projects/my-project/zones/us-west1-a'. Values must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?', invalidParameter

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
-/+ google_compute_disk.blog (new resource required)
      disk_encryption_key_sha256: "" => "<computed>"
      name:                       "blog" => "blog"
      self_link:                  "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-west1-a/disks/blog" => "<computed>"
      size:                       "10" => "10"
      snapshot:                   "https://www.googleapis.com/compute/v1/projects/my-project/global/snapshots/blog-2017-07-12-1" => "blog-2017-07-12-1" (forces new resource)
      type:                       "pd-ssd" => "pd-ssd"
      users.#:                    "1" => "<computed>"
      zone:                       "us-west1-a" => "us-west1-a"

@rileykarson
Copy link
Collaborator

@nodesocket: It looks like the snapshot forcing a recreate is the same issue as this, but the detach failing looks like a separate issue to me; would you mind filing another issue with the first block & with a repro config?

@nodesocket
Copy link
Contributor

@rileykarson there is already an issue that was ported over: #112

@rileykarson
Copy link
Collaborator

Oh cool - I'd missed that one, thanks!

z1nkum pushed a commit to z1nkum/terraform-provider-google that referenced this issue Aug 15, 2017
negz pushed a commit to negz/terraform-provider-google that referenced this issue Oct 17, 2017
@danawillow
Copy link
Contributor

This was fixed in #238, closing.

luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this issue May 21, 2019
<!-- This change is generated by MagicModules. -->
/cc @danawillow
@ghost
Copy link

ghost commented Mar 29, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants