Terraform Remote State & Locking — Challenge
45 minIntermediate
This creates billable resources. Run it in a dev environment and destroy it when you finish. Set a budget alarm first.
You are done when
0 of 4
The goal#
Achieve the same outcome as Terraform Remote State & Locking, from an empty starting point, without the steps.
State is on your laptop. A colleague runs terraform apply from theirs, sees none of your resources, and creates a second copy of everything — or worse, destroys yours.
This is the lab that makes Terraform usable by more than one person.
What must be true when you are done#
- State lives in S3, and
terraform.tfstateis no longer written locally. - The bucket has versioning and encryption enabled, and blocks public access.
- A second
applystarted while the first is running fails with a lock error rather than proceeding. - You migrated existing state without any resource being destroyed and recreated.
Rules#
- Do not open the guided lab until you are finished, or until the same problem has held you up for 20 minutes.
- Documentation is allowed. In the job it is the first thing you open.
- Verify every criterion with a command whose output you can read.
If you get stuck#
- What did you expect, exactly?
- What happened instead — the error text, not a paraphrase?
- Which layer is that error from?
- What is the smallest command that proves the layer below is fine?