PaC(Policy as Code)

インフラのルール(「S3は公開しない」など)をコードで書いて、自動でチェックすること。

PlanとPaCの組み合わせ

  • terraform plan の結果をJSONで出し、それをポリシーでチェックする
  • 実際に作られる差分を apply の前に止められる
terraform plan -out=tfplan
terraform show -json tfplan > tfplan.json
checkov -f tfplan.json