A cloud engineering team wants to store Terraform state files remotely in Google Cloud to support team collaboration and state locking. Which TWO steps are required to configure a Cloud Storage bucket as a remote backend for Terraform?
- Create a Cloud Storage bucket in Google Cloud to store the Terraform state file.Answer
- Add a `backend "gcs"` block inside the Terraform configuration and specify the bucket name.Answer
- CEnable the Cloud Monitoring API in the organization root project to initialize state locking.
- DGenerate and export long-lived JSON service account keys to be committed into the shared source repository.
Answer
The two required steps are creating a Cloud Storage bucket in Google Cloud to host the state file, and defining a `backend "gcs"` configuration block specifying that bucket.
To set up a remote state backend in Google Cloud using Terraform, you must create a GCS bucket and configure the `backend "gcs"` block in your Terraform configuration files before executing `terraform init`.
Step-by-Step Solution
Key Concept
Configuring Cloud Storage (GCS) as a remote backend for Terraform state