// writing

Policy as Code with OPA and Terraform

5 articles

Policy as code puts a check between terraform plan and apply, so a dangerous change fails the pipeline instead of reaching your AWS accounts. Read the series in this order:

  1. The incident: a deleted state bucket and the guardrail that came out of it.
  2. The first policy: a Rego rule for force_destroy, tested with Conftest and run in CI.
  3. Required AWS tags: tag keys and allowed values, per environment.
  4. Approved AMIs: only images from an approved list.

Shift-left cost checks applies the same idea to cloud cost.