iac.htora.dev · security templates

Home/Templates/Check every resource against your rules, all the time

Check every resource against your rules, all the time

Continuous evaluation that flags a resource the moment it stops matching the standard.

Terraform

Why bother

A yearly assessment is out of date the week after it is signed. This runs on every change and shows what drifted, with a date on it.

How you know it worked

Create something that breaks a rule. It should show up as failing within one cycle.

How it works

1A resource changescreated, edited, or deleted2The evaluator runsagainst a named set of rules3Compliant or notwith the time it changed4Optional automatic fixwhere the fix is safe to automate
Step by step, from the thing that happens to the result you want.

Set it up

Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.

Terraform. AWS Config with a conformance pack

What you need first

  • An account and region where AWS Config is not already running, or rights to import the existing recorder.
  • For Standard, an SNS topic whose policy lets events.amazonaws.com publish.

What it creates

  • A Config recorder for every supported resource, with history delivered to a bucket
  • Six AWS managed rules, each checked as resources change
  • A conformance pack of thirteen rules, and history encrypted under its own key and kept seven years (Standard)
  • An alert on every noncompliant result, and optional automatic repair of public buckets (Standard)

See the one alert this creates

The code

Quick startReadyone file, 144 lines
One file. Config recording every resource, and six managed rules.
Run it
  1. aws sts get-caller-identity
    Shows the account and role you are signed in as. Check it before every apply.
  2. terraform init
    Downloads the provider. Run it once per folder.
  3. terraform plan
    Shows what will be created. Changes nothing. Read it.
  4. terraform apply
    Shows the plan again and waits for you to type yes.
  5. terraform destroy
    When you have finished. If it refuses, How to undo it below explains why.
Download main.tf
Checks

Formatting passedValid passedLint passed

Security scan: 24 checks passed, and six rules flagged, each with a written reason:

Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.

outcomes/compliance-evaluation/aws/t0
main.tf
Open main.tf as plain text
StandardReadyfour files, 385 lines
Adds a thirteen-rule conformance pack, encrypted history kept seven years, an alert on every noncompliant result, and optional automatic repair of public buckets.
Change these first
  • alert_topic_arn. SNS topic told when any rule finds a noncompliant resource. Its policy must let events.amazonaws.com publish.
Run it
  1. aws sts get-caller-identity
    Shows the account and role you are signed in as. Check it before every apply.
  2. # terraform.tfvars
    alert_topic_arn = ""
    Create this file beside the others and fill in your values. Terraform reads it on its own.
  3. terraform init
    Downloads the provider. Run it once per folder.
  4. terraform plan
    Shows what will be created. Changes nothing. Read it.
  5. terraform apply
    Shows the plan again and waits for you to type yes.
  6. terraform output verify
    Prints the commands that prove it worked.
Download all four files as a zip
Checks

Formatting passedValid passedLint passed

Security scan: 53 checks passed, and six rules flagged, each with a written reason:

Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.

outcomes/compliance-evaluation/aws/t1
main.tf
Open main.tf as plain text
outputs.tf
Open outputs.tf as plain text
variables.tf
Open variables.tf as plain text
versions.tf
Open versions.tf as plain text
HardenedReadysix files, 214 lines
Standard as a module. Plan rules refuse the recorder, pack, bucket, or alert deleted, recording switched off or narrowed, public access allowed, versioning off, encryption other than KMS, key rotation off. A daily plan reports drift, and the scan fails on any unexplained finding.
Change these first
  • alert_topic_arn. SNS topic told when any rule finds a noncompliant resource. Its policy must let events.amazonaws.com publish.
Run it
  1. aws sts get-caller-identity
    Shows the account and role you are signed in as. Check it before every apply.
  2. # terraform.tfvars
    alert_topic_arn = ""
    Create this file beside the others and fill in your values. Terraform reads it on its own.
  3. terraform init
    Downloads the provider. Run it once per folder.
  4. terraform plan
    Shows what will be created. Changes nothing. Read it.
  5. terraform apply
    Shows the plan again and waits for you to type yes.
  6. terraform output verify
    Prints the commands that prove it worked.
Download all six files as a zip
Checks

Formatting passedValid passedLint passed

Security scan: 47 checks passed, and none flagged.

Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.

outcomes/compliance-evaluation/aws/t2
.checkov.yml
Open .checkov.yml as plain text
guard.yml
Open guard.yml as plain text
main.tf
Open main.tf as plain text
outputs.tf
Open outputs.tf as plain text
variables.tf
Open variables.tf as plain text
versions.tf
Open versions.tf as plain text

How to check it worked

Create a security group that allows port 22 from anywhere. Within a few minutes the restricted-ssh rule lists it as noncompliant.

What catches people

Each account and region allows one recorder. If Control Tower or Security Hub already set Config up, apply fails. Use what is there, or import it.

IAM resources are global. Record them in one region only, or every region records and bills for them.

Automatic repair of public buckets also fixes buckets meant to be public, such as a static website. Standard leaves it off until you switch it on.

Config bills per resource change recorded, so a busy account costs more. Check the first week's bill.

How to undo it

terraform destroy stops recording and removes the rules and the pack. The quick start's history bucket is deleted with it; Standard's has no force delete, so empty it first.

What it costs

Per configuration change recorded and per rule evaluation. A quiet account costs a few dollars a month; a busy one can cost far more.

Good to know

  • Evaluation catches drift after it happens; the guardrail template stops some of it before. They work together: a guardrail for what must never happen, a rule for what should be fixed.
  • A noncompliant result is only useful if someone sees it. Standard sends each one to the alert topic as it happens.

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.