Challenge - 5 Problems
GCS Backend Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Configuration
intermediate2:00remaining
Identify the correct GCS backend configuration block
Which Terraform backend configuration block correctly sets up Google Cloud Storage (GCS) as the backend with bucket name my-terraform-state and prefix env/prod?
Attempts:
2 left
💡 Hint
The GCS backend requires the bucket name under the key 'bucket' and the state file path prefix under 'prefix'.
✗ Incorrect
The correct keys for GCS backend are 'bucket' for the bucket name and 'prefix' for the folder path inside the bucket. Other keys like 'bucket_name', 'path', or 'prefix_path' are invalid and cause errors.
❓ service_behavior
intermediate1:30remaining
What happens if the GCS backend bucket does not exist?
When Terraform initializes with a GCS backend configuration pointing to a non-existent bucket, what is the expected behavior?
Attempts:
2 left
💡 Hint
Terraform requires the backend storage bucket to exist before initialization.
✗ Incorrect
Terraform does not create GCS buckets automatically. If the bucket does not exist, initialization fails with an error indicating the missing bucket.
❓ security
advanced2:00remaining
Which IAM role is required for Terraform to write state to a GCS backend?
To allow Terraform to store and update state files in a GCS bucket, which minimum IAM role should be granted to the service account used by Terraform?
Attempts:
2 left
💡 Hint
Terraform needs permissions to read, write, and delete objects in the bucket.
✗ Incorrect
The 'roles/storage.objectAdmin' role allows full control over objects in the bucket, including creating, updating, and deleting state files. 'objectViewer' is read-only, 'objectCreator' cannot delete or overwrite, and 'storage.admin' is broader than needed.
❓ Architecture
advanced2:30remaining
How to configure Terraform backend for multiple environments using GCS?
You want to manage separate Terraform states for 'dev' and 'prod' environments using the same GCS bucket named tf-states. Which backend configuration correctly isolates the states?
Attempts:
2 left
💡 Hint
Use different prefixes inside the same bucket to separate state files per environment.
✗ Incorrect
Terraform backend configuration supports one backend block per configuration. To manage multiple environments, use different prefixes inside the same bucket. Option B is invalid because you cannot have two backend blocks in one config. Option B is invalid syntax. Option B is a valid approach but not a backend configuration example.
✅ Best Practice
expert3:00remaining
What is the recommended way to secure Terraform state files in GCS?
Which practice best secures Terraform state files stored in a GCS bucket?
Attempts:
2 left
💡 Hint
Protect state files by controlling access, encrypting data, and keeping history.
✗ Incorrect
Best practice is to enable versioning to keep history, restrict IAM roles to only those who need access, and use CMEK for stronger encryption control. Public access or overly broad permissions expose sensitive data and risk state corruption.