Cloud / DevOps Engineer · Projects

Project 1: An environment from code

Marking guide version 1 · Lessons: CD1 lessons 2–4, CD2 lessons 1–2 and 4–5, CD3 lessons 2–5, CD10 lesson 2

The problem and who it's for

RouteRani's environment works, but only just. The image is 1.6 GB and runs as root; the database password is written in the Terraform files; the database is published on the host and keeps its data inside the container; there's one API copy using latest; and nobody is sure a rebuild would come out the same. Priya, who books the Jaipur–Udaipur bus every month, shouldn't lose her booking because someone replaced a container.

Scope

Not included

Before you start

Starter files

Download everything at once: starter/cloud-devops-starter.zip.

Milestones

  1. Run npm run test:infra and note which of the 10 tests fail and why.
  2. Rewrite the Dockerfile and add .dockerignore (test 3).
  3. Pin providers, generate the password and remove latest (tests 1 and 2).
  4. Make the database private with a volume and health check (tests 6 and 9).
  5. Add the variables, copies, outputs and lifecycle settings (tests 4, 5, 7 and 8).
  6. Run destroy and rebuild (test 10), then all 10 tests twice in a row.

Expected outputs

Acceptance tests

# Input Expected result
1 npm run test:infra 10 of 10 pass, twice in a row
2 git grep -n routerani123 in your kit No results
3 docker inspect on the database container No published ports; status healthy (test 6)
4 A booking, then terraform apply -replace=docker_container.db The booking is still there (test 9)
5 docker rm -f one API copy, then terraform plan -detailed-exitcode and apply Exit code 2, then the copy is back and the next plan exits 0 (tests 7 and 8)
6 terraform destroy, then terraform apply Nothing left behind after destroy; 40 routes served after the rebuild (test 10)

Failure and recovery exercises

  1. Stop the database container by hand during traffic. Write down what /ready returns, what nginx does, and what terraform plan shows. Then repair it with terraform apply.
  2. Add depends_on = [docker_container.db] to the API copies and try terraform apply -replace=docker_container.db. Explain the error in two sentences, then remove it.
  3. Remove memory_swap and run terraform plan right after an apply. Explain the change it shows, then put it back.

Evidence to submit

Marking guide and self-check

Pass rule: every Safety-critical (S) and Mandatory (M) item must be met. A single unmet safety item means the project is not complete, whatever else is done. Quality items are for your own improvement.

Your answers are saved in this browser on this device. Self-checked means you checked your own work against this guide; it is not a reviewer's approval. Never paste passwords, keys, tokens or real customer data here.

Checklist (marking guide version 1)
Evidence

← PreviousAll projects
ProLearners Assist