0
0
Terraformcloud~10 mins

GCS backend configuration in Terraform - 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 Google Cloud Storage in Terraform.

Terraform
terraform {
  backend "[1]" {
    bucket = "my-terraform-state"
    prefix = "terraform/state"
  }
}
Drag options to blanks, or click blank then click option'
Alocal
Bgcs
Cazurerm
Ds3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 's3' instead of 'gcs' for the backend type.
Using 'local' which stores state on the local machine.
2fill in blank
medium

Complete the code to specify the GCS bucket name in the backend configuration.

Terraform
terraform {
  backend "gcs" {
    bucket = "[1]"
    prefix = "terraform/state"
  }
}
Drag options to blanks, or click blank then click option'
Amy-terraform-state
Bmy-project-bucket
Cterraform-state-bucket
Dstate-bucket-123
Attempts:
3 left
💡 Hint
Common Mistakes
Using a bucket name that does not exist.
Leaving the bucket name blank.
3fill in blank
hard

Fix the error in the backend configuration by completing the missing prefix value.

Terraform
terraform {
  backend "gcs" {
    bucket = "my-terraform-state"
    prefix = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Aterraform/state
Bstate/terraform
Cterraformstate
Dstate
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid or empty prefix.
Using a prefix without a slash which can cause confusion.
4fill in blank
hard

Fill both blanks to configure the backend with project and credentials file.

Terraform
terraform {
  backend "gcs" {
    bucket      = "my-terraform-state"
    prefix      = "terraform/state"
    project     = "[1]"
    credentials = "[2]"
  }
}
Drag options to blanks, or click blank then click option'
Amy-gcp-project
B/path/to/credentials.json
Ccredentials.json
Dgcp-project-123
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the filename for credentials instead of full path.
Using wrong project ID format.
5fill in blank
hard

Fill all three blanks to complete the backend configuration with bucket, prefix, and project.

Terraform
terraform {
  backend "gcs" {
    bucket  = "[1]"
    prefix  = "[2]"
    project = "[3]"
  }
}
Drag options to blanks, or click blank then click option'
Aterraform-state-bucket
Bterraform/state
Cmy-gcp-project
Dstate/terraform
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up prefix and project values.
Using invalid bucket names.