Interview Prep/Terraform/State Locking and Backend Errors

`terraform plan` takes 10 minutes and then fails with `Error acquiring the state lock` and `context deadline exceeded`, only from the corporate network.

IntermediateTroubleshootingState Locking and Backend Errors
Answer

Likely causes → A proxy or firewall blocks or slows the DynamoDB/S3 endpoint; HTTPS_PROXY is set but NO_PROXY routes VPC endpoints incorrectly; DNS resolves S3 to a private endpoint you can't reach.

Diagnose →

env | grep -i proxy
TF_LOG=DEBUG terraform plan 2>&1 | grep -E 'dynamodb|s3\.|timeout'
curl -sv https://dynamodb.ap-south-1.amazonaws.com 2>&1 | head

Fix → Configure the proxy correctly (and trust its CA via the OS store or AWS_CA_BUNDLE), or run Terraform from a runner inside the VPC.

Prevent → Run shared-state Terraform from controlled runners, not from laptops on varied networks. -lock-timeout=5m helps only with genuine contention, not network issues.

All Terraform questions Roadmap: Terraform in production

More on State Locking and Backend Errors