Skip to content

Commit

Permalink
Add moved
Browse files Browse the repository at this point in the history
  • Loading branch information
toshi0607 committed Aug 28, 2022
1 parent eb8d3c6 commit e5b0323
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Samples are explained in the below books.
* [Remote backend](./remote-backend)
* [Separate state by backend end environment](./state-separation)
* [terraformer](./terraformer-test)
* [moved](./moved)

## Practical edition

Expand Down
9 changes: 9 additions & 0 deletions moved/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions moved/README.md
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
```
22 changes: 22 additions & 0 deletions moved/main.tf
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"
}
}

0 comments on commit e5b0323

Please sign in to comment.