-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This example doesn't specify a credential and a project intentionally. | ||
|
||
```shell | ||
$ gcloud auth application-default login | ||
|
||
# export GOOGLE_PROJECT=terraform-toshi0607 | ||
# 【YOUR PROJECT】をあなたのGCPプロジェクトに置き換えてください。 | ||
$ export GOOGLE_PROJECT=【YOUR PROJECT】 | ||
|
||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
|
||
# Change resource name from before-move to after-move | ||
# Confirm resource recreation (+ create and -destroy) would happen | ||
$ terraform plan | ||
|
||
# Enable (comment in moved block) | ||
# Confirm resource recreation would NOT happen | ||
$ terraform plan | ||
$ terraform apply | ||
|
||
$ terraform destroy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
moved { | ||
from = google_compute_instance.before-move | ||
to = google_compute_instance.after-move | ||
} | ||
|
||
resource "google_compute_instance" "after-move" { | ||
# resource "google_compute_instance" "before-move" { | ||
name = "moved" | ||
machine_type = "f1-micro" | ||
zone = "asia-northeast1-c" | ||
|
||
boot_disk { | ||
initialize_params { | ||
# gcloud compute images list | grep debian, if the image can't be found | ||
image = "debian-cloud/debian-11" | ||
} | ||
} | ||
|
||
network_interface { | ||
network = "default" | ||
} | ||
} |