0
0
Terraformcloud~10 mins

Why state is essential in Terraform - Test Your Understanding

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

Complete the code to initialize Terraform state.

Terraform
terraform [1]
Drag options to blanks, or click blank then click option'
Aapply
Binit
Cplan
Ddestroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' before initializing causes errors.
Confusing 'plan' with initialization.
2fill in blank
medium

Complete the code to show the current Terraform state.

Terraform
terraform [1]
Drag options to blanks, or click blank then click option'
Aapply
Bplan
Cstate list
Ddestroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' or 'plan' to view state.
Trying to read state without initializing.
3fill in blank
hard

Fix the error in the backend configuration to enable remote state storage.

Terraform
terraform {
  backend "[1]" {
    bucket = "my-terraform-state"
    region = "us-west-2"
  }
}
Drag options to blanks, or click blank then click option'
As3
Blocal
Cgcs
Dazurerm
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' backend when remote storage is needed.
Confusing cloud providers in backend names.
4fill in blank
hard

Fill both blanks to configure Terraform to lock state during operations.

Terraform
terraform {
  backend "s3" {
    bucket         = "my-terraform-state"
    region         = "us-west-2"
    [1] = true
    [2] = "dynamodb-table"
  }
}
Drag options to blanks, or click blank then click option'
Aencrypt
Block_table
Cdynamodb_table
Dlock
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect key names like 'lock_table' or 'lock'.
Forgetting to enable encryption.
5fill in blank
hard

Fill all three blanks to output the current state file path and its format.

Terraform
output "state_info" {
  value = {
    path   = "[1]"
    format = "[2]"
    size   = [3]
  }
}
Drag options to blanks, or click blank then click option'
Aterraform.tfstate
Bjson
C1024
Dstate.tf
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect file names or formats.
Confusing size with string instead of number.