Adopt an Existing Value With an import Block
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.
/home/student/infra/indexer has never been applied. It picks a listening port with random_integer.port (between 8000 and 8999) and writes /home/student/out/listen.conf. But the service already runs on port 8123, assigned by hand (see ports.txt), and the firewall rules depend on it. A plain tofu apply would pick a random new port.
Bring the existing port under management with an import block, so that after your apply:
random_integer.port in the state has the result 8123 (min 8000, max 8999),/home/student/out/listen.conf contains listen 8123,The random provider imports a random_integer from an ID of the form RESULT,MIN,MAX.
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.
Part of Prepare for the Terraform Associate. Next step: Stop Managing a Resource Without Destroying It
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.