Rename a Resource Without Replacing It

medium 20 XP ~7 minHands-on lab Pro

This machine has OpenTofu, the open-source tool that reads the same configuration language as Terraform. Run it as tofu (terraform runs the same program). There is no network: the local, random and null providers are already installed.

In /home/student/infra/relay, the resource random_pet.name generates the public name of a running server. The team wants it called random_pet.server_name. A naïve rename would destroy the old name and generate a new one, breaking every link.

Task

  • In the code, the resource is called random_pet.server_name (nothing is called random_pet.name any more).
  • The state tracks it as random_pet.server_name with the same value as before.
  • The file /home/student/out/hostname.txt keeps the same content.
  • A new plan reports no changes.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

TerminalNot started

Your machine is ready to start

Create a free account to open a machine and get graded.