Back to Initiative Library
Config & Standards Low complexity

Update IaC Resource Makefile

✦ Sample Prompt
Update the IaC `Makefile` in every infrastructure repo to match the canonical
template.

Canonical targets (customize before running):
  .PHONY: init plan apply fmt validate destroy

  init:
  	tfenv install && terraform init -upgrade

  plan:
  	terraform plan -var-file=terraform.tfvars -out=plan.out

  apply:
  	terraform apply plan.out

  fmt:
  	terraform fmt -recursive

  validate:
  	terraform fmt -check -recursive && terraform validate

For each repository:
1. Locate the IaC `Makefile` at the repo root (or `infra/Makefile`,
   `terraform/Makefile`).
2. Replace these targets with the canonical versions: `init`, `plan`, `apply`,
   `fmt`, `validate`. Preserve any custom targets unless they conflict.
3. Update `.PHONY:` to list every target the Makefile defines.
4. Preserve blocks marked with `# tidra:keep` and `# tidra:end` comments verbatim.
5. If the repo uses `asdf` or `mise` instead of `tfenv`, substitute the appropriate
   install command in the `init` target (configurable in the prompt).
6. Skip repos whose Makefile already matches the template.

The Problem

The `Makefile` in each IaC repo is the human and CI interface to the resource: `make plan`, `make apply`, `make fmt`. Over time these drift, some repos use `terraform` directly, others use `tfenv`, some pin `-var-file` flags inconsistently, and the `fmt` target sometimes runs `terraform fmt` without `-recursive`.

Bringing every Makefile in line with the current standard means a small but consistent set of edits across every IaC repo.

What Tidra Does

  1. Locates the IaC Makefile in every infra repo
  2. Replaces drifted targets (plan, apply, fmt, validate, init) with the canonical versions from a template you provide
  3. Preserves repo-specific extras (custom targets, env-var defaults) by merging rather than overwriting
  4. Updates the shebang line and the .PHONY declaration to match the new target list
  5. Opens one PR per repo with a unified diff showing exactly what changed

Before & After

diff
Makefile
@@ -1,8 +1,12 @@
- .PHONY: plan apply
+ .PHONY: init plan apply fmt validate
+ init:
+ tfenv install && terraform init -upgrade
+
plan:
- terraform plan
+ terraform plan -var-file=terraform.tfvars -out=plan.out
apply:
- terraform apply
+ terraform apply plan.out
+ fmt:
+ terraform fmt -recursive

Customization Tips

  • Template Makefile: Point Tidra at the canonical Makefile template. It will diff each repo against the template and converge.
  • Repo-specific extras: Mark extras to preserve with a # tidra:keep comment block. Tidra will leave them alone.
  • tfenv vs asdf: If your org uses asdf or mise instead of tfenv, swap the init target accordingly.

Ready to run this across your repos?

Connect your Git provider and Tidra opens pull requests in every repo that needs them.