The Makefile: Your Day-to-Day Commands

You rarely type raw tofu commands in this repo - the Makefile wraps them so they're consistent. A Makefile is just a list of named command shortcuts (targets); you run make <target>. The variables DIR (which root) and ENV (which account/workspace) parameterize them.

Command What it does
make fmt Format every .tf file in the repo.
make validate Backend-less init + validate of every root - no AWS credentials needed. Run this before committing.
make bootstrap-apply ENV=dev Create/refresh the state backend for the dev account (selects the dev workspace, applies dev.tfvars).
make backend-config DIR=envs/dev ENV=dev Pull the KMS key ARN from bootstrap's output and write it into envs/dev/backend.s3.tfbackend.
make init DIR=envs/dev Initialize a root against its remote backend.
make plan DIR=envs/dev Preview changes for one root.
make apply DIR=envs/dev Apply one root - break-glass only; normally the pipeline applies.
make destroy DIR=envs/dev Tear down one root.
make lint Run tflint across the repo.
make clean Remove local .terraform dirs and plan files.

A typical first-time-through-dev sequence (from the README/SETUP):

BASH
tenv install && pre-commit install                          # one-off tooling setup
cp bootstrap/dev.tfvars.example bootstrap/dev.tfvars        # set account ID + bucket name
make bootstrap-apply ENV=dev                                # create the state backend
cp envs/dev/terraform.tfvars.example envs/dev/terraform.tfvars
make backend-config DIR=envs/dev ENV=dev                    # wire the backend
make init DIR=envs/dev
make plan DIR=envs/dev                                      # preview; the pipeline owns apply
Adesh Tamrakar
SOFTWARE ENGINEER · VAULT

Notes, insights and random discoveries from a working engineer's vault - written for future me, published for you.