0
0
Terraformcloud~10 mins

Workspaces and remote state 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 select the current Terraform workspace.

Terraform
terraform.workspace == "[1]"
Drag options to blanks, or click blank then click option'
Adev
Bmain
Cprod
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' or 'prod' as the default workspace name.
Confusing workspace names with environment names.
2fill in blank
medium

Complete the code to configure a remote backend with an S3 bucket named 'my-terraform-state'.

Terraform
backend "s3" {
  bucket = "[1]"
  key    = "state.tfstate"
  region = "us-east-1"
}
Drag options to blanks, or click blank then click option'
Aterraform-state-bucket
Bstate-bucket
Cmy-terraform-state
Dterraform-bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic bucket name instead of the specified one.
Confusing the bucket name with the key or region.
3fill in blank
hard

Fix the error in the backend configuration by completing the missing attribute for DynamoDB table used for state locking.

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'
Aterraform-locks
Bstate-locks
Cterraform-state-lock
Dlocks-table
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or generic table names.
Omitting the locking table causing concurrency issues.
4fill in blank
hard

Fill both blanks to create a workspace and select it using Terraform CLI commands.

Terraform
terraform workspace [1] myworkspace
terraform workspace [2] myworkspace
Drag options to blanks, or click blank then click option'
Aworkspace
Bselect
Cnew
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'init' instead of 'new' to make a workspace.
Selecting a workspace before creating it.
5fill in blank
hard

Fill all three blanks to configure a remote backend with S3 bucket, DynamoDB table for locking, and enable encryption.

Terraform
backend "s3" {
  bucket         = "[1]"
  key            = "terraform.tfstate"
  region         = "us-west-2"
  dynamodb_table = "[2]"
  encrypt        = [3]
}
Drag options to blanks, or click blank then click option'
Amy-remote-state
Bterraform-lock-table
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting encrypt to false or omitting it.
Using wrong bucket or table names.