terraform plan showing diff after import of GCE persistent disk

223 views Asked by At

I had to restore a GCE persistent disk from snapshot. Now I wanted to import the new disk to terraform.

So I did:

terragrunt import google_compute_region_disk.region_disk projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00

This works as I can correct snapshot id in remote state file. So, state file is refreshed fine. However when I do terragrunt plan, it shows me the difference and wants to delete my existing disk.

Terraform will perform the following actions:

  # google_compute_region_disk.region_disk will be destroyed
  - resource "google_compute_region_disk" "region_disk" {
      - creation_timestamp        = "2022-03-15T18:11:16.301-07:00" -> null
      - id                        = "projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00" -> null
      - label_fingerprint         = "nT7_dAxskBs=" -> null
      - labels                    = {
          - "goog-gke-volume" = ""
        } -> null
      - last_attach_timestamp     = "2022-03-15T18:13:37.907-07:00" -> null
      - name                      = "ops-syd-jenkins-00" -> null
      - physical_block_size_bytes = 4096 -> null
      - project                   = "my-project" -> null
      - region                    = "australia-southeast1" -> null
      - replica_zones             = [
          - "https://www.googleapis.com/compute/v1/projects/my-project/zones/australia-southeast1-b",
          - "https://www.googleapis.com/compute/v1/projects/my-project/zones/australia-southeast1-a",
        ] -> null
      - self_link                 = "https://www.googleapis.com/compute/v1/projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00" -> null
      - size                      = 64 -> null
      - snapshot                  = "https://www.googleapis.com/compute/v1/projects/my-project/global/snapshots/ops-syd-jenkins-00-australia-southea-20220314173349-1k0o9ddg" -> null
      - source_snapshot_id        = "1331153218805351057" -> null
      - type                      = "pd-ssd" -> null
      - users                     = [
          - "https://www.googleapis.com/compute/v1/projects/my-project/zones/australia-southeast1-b/instances/gke-ops-syd-02-ops-n2s8-2021040716053-76d39e68-wz86",
        ] -> null

      - timeouts {}
    }

  # google_compute_region_disk.region_disk["ops-syd-jenkins-00"] will be created
  + resource "google_compute_region_disk" "region_disk" {
      + creation_timestamp        = (known after apply)
      + id                        = (known after apply)
      + label_fingerprint         = (known after apply)
      + labels                    = {
          + "goog-gke-volume" = ""
        }
      + last_attach_timestamp     = (known after apply)
      + last_detach_timestamp     = (known after apply)
      + name                      = "ops-syd-jenkins-00"
      + physical_block_size_bytes = (known after apply)
      + project                   = "my-project"
      + region                    = "australia-southeast1"
      + replica_zones             = [
          + "https://www.googleapis.com/compute/v1/projects/my-project/zones/australia-southeast1-b",
          + "https://www.googleapis.com/compute/v1/projects/my-project/zones/australia-southeast1-a",
        ]
      + self_link                 = (known after apply)
      + size                      = 64
      + snapshot                  = "https://www.googleapis.com/compute/v1/projects/my-project/global/snapshots/ops-syd-jenkins-00-australia-southea-20220314173349-1k0o9ddg"
      + source_snapshot_id        = (known after apply)
      + type                      = "pd-ssd"
      + users                     = (known after apply)
    }

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

Not sure what I am doing wrong. Thanks.

1

There are 1 answers

0
Kumar Gaurav On

My bad, it was a bad import. Needed to run following to import:

terragrunt import google_compute_region_disk.region_disk["ops-syd-jenkins-00"] projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00