18/53
Sign inSign up free

860. Health Checks With a check Block

medium 20 XP ~10 minHands-on lab

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.

The app deployed by /home/student/infra/syncd reports its state in /home/student/out/status.json, like {"status": "ok", "version": "1.4.0"}. The team wants every plan to warn when the app isn't healthy, but never to fail because of it (also not when the status file is missing during a first deploy).

Task

Add a check block named app_healthy that:

  • reads /home/student/out/status.json with a local_file data source inside the check block,
  • asserts that its status is ok, with the error message The app is not healthy: <status> (for example The app is not healthy: degraded).

With a healthy app, a plan shows no warning and nothing to add, change or destroy.

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.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

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.