Course outlines for learning terraform.
expected time | requirements |
---|---|
45 minutes | A computer and terraform knowledge. |
Goal: See how remote state on GCP works.
So far you have been using a “local state”, basically just some files in your repository. This does not allow collaboration, the state is only on your laptop.
There are multiple reasons to use remote state:
This example looks at Google mostly, but there are many more place where you can store remote state:
Do not confuse the data object remote state with remote state. (Although it’s interesting!)
See this repo.
In this assignment we are going to migrate the local state to GCP.
terraform apply
to create the resources. State will be local.You are now ready to migrage state.
terraform.tf
and set the backend
to gcs
.bucket
.prefix
.terraform init -migrate-state
.When you’ve answered ‘yes’, your state is remote. We’re going to migrate back to a local state file.
terraform.tf
.terraform init -migrate-state
.When you’ve answerd ‘yes’, your state is now local again.