[ norboten ]
terraform · lab terraform-01

The Rename That Wants to Destroy

· about 35 minutes · runs on ubuntu-26.04-devops · unrated

An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.

The briefing

/srv/infra is the Terraform configuration for the shop's local settings: a generated session key, /etc/shop/app.env built from it, and the web server's site file /etc/shop/nginx-site.conf. Its state is the local terraform.tfstate in the same directory.

A pull request renamed the resources to the names the team agreed on — random_password.session_key and local_file.app_env. The first terraform plan after the merge wants to destroy and recreate the session key, which would log out every customer. Nobody has applied it. The plan also wants to replace the site file, which someone edited by hand on this machine during an incident.

What is expected, and graded:

  1. terraform plan in /srv/infra reports no changes.
  2. The session key is the one that exists today — in the state, under the new name, and in /etc/shop/app.env. The new resource names stay.
  3. The state file, and any backup of it, can be read by root only.

Terraform's providers are already on the machine; there is no internet access. You have root through sudo. Everything must still hold after a reboot.

What is graded

The machine is checked, rebooted, and checked again. A check passes only if it passes both times.

CheckObjective
01_plan_is_cleanBring drifted infrastructure back to its configuration
02_session_key_keptRefactor Terraform configuration without replacing what already exists
03_state_protectedProtect a state file that holds secrets

Start it

  1. 2Labs
  2. terraform-01select this one
  3. udownload it
  4. sstart the machine

Reading

Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).

Theory for this lab

4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:

Question 1

A resource block is renamed from `hcloud_volume.logs` to `hcloud_volume.access_logs` with no other change. What does the next plan propose?

Question 2

What does `terraform plan -detailed-exitcode` exit with when the plan has changes to make?

Question 3

A `random_password` is declared with its value marked sensitive. Where can its generated value still be read in plain text?