0
0
Terraformcloud~10 mins

State file performance at scale 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 storing Terraform state remotely.

Terraform
terraform {
  backend "[1]" {}
}
Drag options to blanks, or click blank then click option'
As3
Bhttp
Clocal
Dfile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' backend which stores state on the local machine, not suitable for scale.
Using 'file' backend which is similar to local storage.
2fill in blank
medium

Complete the code to enable state locking using DynamoDB to prevent concurrent state modifications.

Terraform
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "state.tfstate"
    region         = "us-east-1"
    dynamodb_table = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Alock-table
Bstate-lock
Cterraform-locks
Dterraform-state-lock
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic or unrelated table name that doesn't match the actual DynamoDB table.
Omitting the dynamodb_table attribute, which disables locking.
3fill in blank
hard

Fix the error in the backend configuration to correctly enable encryption of the state file in S3.

Terraform
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "state.tfstate"
    region         = "us-east-1"
    encrypt        = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"true"
Btrue
CTrue
D"yes"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted strings instead of boolean values causing syntax errors.
Using capitalized True which is invalid in Terraform.
4fill in blank
hard

Fill both blanks to configure the S3 backend with versioning and a custom state file path.

Terraform
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    key            = "[1]"
    region         = "us-east-1"
    versioning     = [2]
  }
}
Drag options to blanks, or click blank then click option'
Aenv/prod/terraform.tfstate
Btrue
Cfalse
Dprod/terraform.tfstate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a simple filename without folders for key, which limits organization.
Setting versioning to false disables state versioning, risking data loss.
5fill in blank
hard

Fill all three blanks to configure remote state with S3 backend, enable locking, and specify the DynamoDB table.

Terraform
terraform {
  backend "s3" {
    bucket         = "[1]"
    key            = "[2]"
    dynamodb_table = "[3]"
    region         = "us-west-2"
  }
}
Drag options to blanks, or click blank then click option'
Acompany-terraform-state
Bprod/terraform.tfstate
Cterraform-locks
Dstate-bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up bucket and DynamoDB table names.
Using generic or incorrect names that don't match actual resources.