我不得不从快照中恢复一个GCE持久磁盘。现在我想将新磁盘导入terraform。
所以我做了:
terragrunt import google_compute_region_disk.region_disk projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00
这是因为我可以更正远程状态文件中的快照id。所以,状态文件刷新得很好。但是,当我执行terragrunt plan
时,它会向我显示差异,并希望删除我现有的磁盘。
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.
不确定我做错了什么。谢谢
糟糕的是,这是一个糟糕的导入。需要运行以下程序才能导入:
terragrunt import google_compute_region_disk.region_disk["ops-syd-jenkins-00"] projects/my-project/regions/australia-southeast1/disks/ops-syd-jenkins-00