Complete the code to specify the backend type for Terraform state storage in GCP.
terraform {
backend "[1]" {
bucket = "my-terraform-state"
prefix = "terraform/state"
}
}The correct backend type for storing Terraform state in Google Cloud Storage is gcs.
Complete the code to enable state locking using a DynamoDB table in AWS (conceptually similar to GCP's state locking).
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "global/s3/terraform.tfstate"
region = "us-west-2"
dynamodb_table = "[1]"
}
}The dynamodb_table value should be the name of the DynamoDB table used for state locking, here 'terraform-state-lock' is a common naming convention.
Fix the error in the Terraform backend configuration for GCP state storage by completing the missing field.
terraform {
backend "gcs" {
bucket = "my-terraform-state"
[1] = "terraform/state"
}
}The prefix field specifies the folder path inside the bucket where the state files are stored.
Fill both blanks to configure Terraform remote state data source to read from a GCS bucket.
data "terraform_remote_state" "network" { backend = "[1]" config = { bucket = "my-terraform-state" prefix = "[2]" } }
The backend must be 'gcs' for Google Cloud Storage, and the prefix is the folder path 'terraform/state' where the state is stored.
Fill all three blanks to define a Terraform backend with GCS bucket, prefix, and credentials file path.
terraform {
backend "[1]" {
bucket = "my-terraform-state"
prefix = "[2]"
credentials = "[3]"
}
}The backend type is 'gcs', prefix is the folder path 'terraform/state', and credentials is the path to the GCP service account key file.