Practical infrastructure challenge
Terraform State and Drift Challenge
Compare desired configuration, recorded Terraform state and observed infrastructure. Diagnose drift, review reconciliation decisions and practice an HCL moved block.
1. Examine the evidence
Catalog environment tag
An operator changed an AWS instance tag from development to test outside the Terraform workflow. Compare desired configuration, recorded state and observed infrastructure before deciding how to reconcile the difference. This is a synthetic example, not a live provider response.
Desired configuration: development
Recorded state: development
Observed infrastructure: test
Inspect the scenario data
{
"resource_address": "aws_instance.catalog",
"attribute": "tags.Environment",
"desired_configuration": "development",
"recorded_state": "development",
"observed_infrastructure": "test",
"context": "An operator changed the tag outside Terraform. The change has not yet been approved as the new desired configuration."
}2. Diagnose state and drift
Loading the practice questions...
Your practice results
3. Construct an address refactor
In a separate provider-free exercise, write a moved block that maps terraform_data.catalog to terraform_data.catalog_metadata. Declare the destination resource with input = "development". Assume the original resource already has that input; do not retain the old resource declaration.
Need a conceptual hint?
Use the old address in the from argument and the new address in the to argument. Declare the resource at its new address, preserving the input.
Compare a reference example after attempting
moved {
from = terraform_data.catalog
to = terraform_data.catalog_metadata
}
resource "terraform_data" "catalog_metadata" {
input = "development"
}Compare the two addresses and resource declaration. In a real workspace, review a plan before applying an address refactor. This editor is for self-comparison, not native Terraform execution.
4. Explain your decision
Explain why a refresh-only plan is not remediation, how approved intent should be represented in configuration, and what evidence would establish that a rename preserves an existing resource. Revisit the scenario without looking at your answers.
Continue your learning
Explore the Drift Analyzer, state locking guide, Plan Review Challenge and learning methodology.
