Write and Reuse a Local Module

medium 20 XP ~10 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.

Two static sites need the same layout. Build it once as a module in /home/student/infra/notifier.

Task

  • Create a module in /home/student/infra/notifier/modules/site with:
    • an input variable name
    • a local_file that writes /home/student/out/sites/NAME/index.html containing <h1>NAME</h1> and a newline
    • an output url with the value https://NAME.example.com
  • In the root configuration (main.tf), call the module twice: module.blog with name blog, and module.shop with name shop.
  • Expose root outputs blog_url and shop_url from the modules' url outputs, and apply.

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.