0
0
GCPcloud~10 mins

State management in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the backend type for Terraform state storage in GCP.

GCP
terraform {
  backend "[1]" {
    bucket = "my-terraform-state"
    prefix = "terraform/state"
  }
}
Drag options to blanks, or click blank then click option'
Agcs
Bs3
Cazurerm
Dlocal
Attempts:
3 left
💡 Hint
Common Mistakes
Using AWS S3 backend type 's3' instead of 'gcs'.
Using local backend which stores state locally.
2fill in blank
medium

Complete the code to enable state locking using a DynamoDB table in AWS (conceptually similar to GCP's state locking).

GCP
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "global/s3/terraform.tfstate"
    region         = "us-west-2"
    dynamodb_table = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Aterraform-locks
Bterraform-state-lock
Cstate-lock-table
Dlock-table
Attempts:
3 left
💡 Hint
Common Mistakes
Using bucket names instead of DynamoDB table names.
Using generic names without 'terraform' or 'lock'.
3fill in blank
hard

Fix the error in the Terraform backend configuration for GCP state storage by completing the missing field.

GCP
terraform {
  backend "gcs" {
    bucket = "my-terraform-state"
    [1] = "terraform/state"
  }
}
Drag options to blanks, or click blank then click option'
Apath
Bkey
Cprefix
Dlocation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'key' which is for S3 backend.
Using 'location' which is for bucket region.
4fill in blank
hard

Fill both blanks to configure Terraform remote state data source to read from a GCS bucket.

GCP
data "terraform_remote_state" "network" {
  backend = "[1]"
  config = {
    bucket = "my-terraform-state"
    prefix = "[2]"
  }
}
Drag options to blanks, or click blank then click option'
Agcs
Bs3
Cnetworking
Dterraform/state
Attempts:
3 left
💡 Hint
Common Mistakes
Using 's3' backend for GCP.
Incorrect prefix folder name.
5fill in blank
hard

Fill all three blanks to define a Terraform backend with GCS bucket, prefix, and credentials file path.

GCP
terraform {
  backend "[1]" {
    bucket      = "my-terraform-state"
    prefix      = "[2]"
    credentials = "[3]"
  }
}
Drag options to blanks, or click blank then click option'
Agcs
Bterraform/state
C/home/user/gcp-key.json
Ds3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 's3' backend instead of 'gcs'.
Wrong prefix folder name.
Missing or wrong credentials file path.