0
0
Terraformcloud~20 mins

State and real infrastructure mapping in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform State Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
How Terraform detects drift in infrastructure

Terraform keeps track of your infrastructure state. What happens when you manually change a resource outside Terraform?

Which option best describes Terraform's behavior when you run terraform plan after such a manual change?

ATerraform crashes with an error about state mismatch.
BTerraform ignores the manual change and shows no difference in the plan.
CTerraform deletes the resource automatically without warning.
DTerraform detects the difference and shows the manual change as a drift to be corrected.
Attempts:
2 left
💡 Hint

Think about how Terraform compares the saved state with the real infrastructure.

Architecture
intermediate
2:00remaining
Best practice for remote Terraform state storage

You want to share Terraform state safely among your team and avoid state conflicts. Which remote backend is the best choice for this purpose?

AKeep the state file in a public GitHub repository.
BStore the state file locally on each developer's machine.
CUse a remote backend like AWS S3 with state locking via DynamoDB.
DUpload the state file manually to a shared email group.
Attempts:
2 left
💡 Hint

Think about safe sharing and preventing simultaneous edits.

Configuration
advanced
2:00remaining
Terraform state locking mechanism

Which of the following Terraform backend configurations correctly enables state locking to prevent concurrent modifications?

Terraform
terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "prod/terraform.tfstate"
    region = "us-west-2"
    # Which option enables locking?
  }
}
AAdd <code>enable_locking = true</code> to enable locking.
BAdd <code>dynamodb_table = "terraform-lock-table"</code> to enable locking with DynamoDB.
CAdd <code>lock = true</code> to enable locking.
DAdd <code>lock_table = "terraform-lock-table"</code> to enable locking.
Attempts:
2 left
💡 Hint

Look for the exact parameter name for DynamoDB locking in S3 backend.

security
advanced
2:00remaining
Protecting sensitive data in Terraform state

Your Terraform state contains sensitive information like passwords and API keys. What is the best way to protect this data in the state file?

AEncrypt the state file at rest using backend encryption features.
BStore sensitive data in plain text variables inside the state file.
CRemove sensitive data from Terraform configuration completely.
DStore the state file unencrypted but restrict file permissions only.
Attempts:
2 left
💡 Hint

Think about encryption and backend capabilities.

🧠 Conceptual
expert
2:00remaining
Terraform state refresh behavior

After running terraform apply, you manually delete a resource in the cloud provider console. What will happen when you run terraform plan next?

ATerraform will show the resource as needing to be created again to match the state file.
BTerraform will ignore the missing resource and show no changes.
CTerraform will delete the resource from the state file automatically.
DTerraform will crash with an error about missing resource.
Attempts:
2 left
💡 Hint

Think about how Terraform compares state with real infrastructure.