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.
Create something that breaks a rule. It should show up as failing within one cycle.
How it works
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 startReady
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: 24 checks passed, and six rules flagged, each with a written reason:
- S3 lifecycle configuration
- S3 event notifications
- S3 cross-region replication
- S3 encrypted with KMS
- S3 server access logging
- S3 versioning on the SIEM failed-events bucket
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.
Open main.tf as plain text
StandardReady
alert_topic_arn. SNS topic told when any rule finds a noncompliant resource. Its policy must let events.amazonaws.com publish.
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.# terraform.tfvars alert_topic_arn = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: 53 checks passed, and six rules flagged, each with a written reason:
- S3 event notifications
- IAM permissions management without constraints
- IAM write access without constraints
- S3 cross-region replication
- S3 server access logging
- IAM resource of *
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
alert_topic_arn. SNS topic told when any rule finds a noncompliant resource. Its policy must let events.amazonaws.com publish.
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.# terraform.tfvars alert_topic_arn = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
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.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
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.
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.
Terraform. The Microsoft cloud security benchmark in Azure Policy, with an alert on each non-compliant change
What you need first
- A subscription, and Resource Policy Contributor and Monitoring Contributor on it.
- For Standard, a management group, and User Access Administrator on it if automatic repair is on.
What it creates
- The Microsoft cloud security benchmark initiative assigned to the subscription, in audit mode
- An activity log alert that emails each time a resource is created or changed into a non-compliant state
- The benchmark at a management group, and alerts for each subscription you name (Standard)
- An optional policy that switches public blob access off as the request arrives, and the command to repair existing accounts after the first evaluation (Standard)
See the one alert this creates
The code
Quick startReady
alert_email = "security-alerts@example.com"main.tf, line 16
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/azurerm 5.6.0.
Open main.tf as plain text
StandardReady
subscription_id. Subscription that contains the alert resources, and that the provider signs in to.management_group_id. Management group the benchmark and the repair policy are assigned to, as /providers/Microsoft.Management/managementGroups/<name>.alert_subscription_ids. Subscriptions whose non-compliant changes send an email. Activity log alerts are set per subscription.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.# terraform.tfvars subscription_id = "" management_group_id = "" alert_subscription_ids = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/azurerm 5.6.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
subscription_id. Subscription that contains the alert resources, and that the provider signs in to.management_group_id. Management group the benchmark and the repair policy are assigned to, as /providers/Microsoft.Management/managementGroups/<name>.alert_subscription_ids. Subscriptions whose non-compliant changes send an email. Activity log alerts are set per subscription.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.# terraform.tfvars subscription_id = "" management_group_id = "" alert_subscription_ids = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/azurerm 5.6.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
The first full evaluation takes a few hours. Then az policy state summarize with the assignment's name shows compliant and non-compliant counts. Standard prints the checks with terraform output verify.
The benchmark is found by its display name. If Microsoft renames it, the lookup fails at plan, and the name in the file needs updating.
Activity log alerts are set per subscription, so a management group assignment still needs each subscription listed for email.
The repair policy rewrites requests with a modify effect. A storage account meant to serve public files stops serving them, so check before switching it on.
The benchmark only audits. Nothing is refused; the guardrail template is where refusals belong.
How to undo it
terraform destroy removes the assignments and the alerts. Accounts the repair policy changed keep public access off.
What it costs
Nothing for Azure Policy on Azure resources. Activity log alerts are free; email notifications are free up to a monthly limit.
Terraform. Security Command Center findings streamed to Pub/Sub, with mute rules and a BigQuery history
What you need first
- Security Command Center switched on for the organisation, with Security Health Analytics on. The Standard tier is free; Terraform cannot switch it on.
- Permission to change IAM on the Pub/Sub topics, because Security Command Center grants its own service account publish rights when a feed is created.
- For Standard, organisation-level Security Command Center admin rights and a security project.
What it creates
- A notification config that streams every active, unmuted finding in one project to a topic
- A subscription that keeps findings for seven days and never expires
- The same for the whole organisation, plus a second feed for high and critical findings (Standard)
- Mute rules for findings you have accepted, each named for its reason (Standard)
- Every finding exported to a BigQuery dataset as a history (Standard)
See the three alerts this creates
The code
Quick startReady
project_id = "your-project-id"main.tf, line 21
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: zero checks passed, and one rule flagged, each with a written reason:
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open main.tf as plain text
StandardReady
org_id. Numeric organisation ID.security_project. Project containing the topics, subscriptions, and findings history.
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.# terraform.tfvars org_id = "" security_project = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and two rules flagged, each with a written reason:
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
org_id. Numeric organisation ID.security_project. Project containing the topics, subscriptions, and findings history.
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.# terraform.tfvars org_id = "" security_project = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Create a firewall rule allowing tcp:22 from anywhere in a scratch project. Once Security Health Analytics raises the finding, it arrives on the subscription.
Security Command Center does the evaluating, and must be switched on before apply. These templates route the findings it raises to the people who act on them.
Which detectors run, and how soon, depends on the tier and the detector. Some findings arrive in minutes, others after the next scan.
A mute removes a finding from the feeds and keeps it on record. Review mutes like firewall exceptions, since each hides a real condition.
How to undo it
terraform destroy removes the feeds, mutes, and export. Findings stay in Security Command Center, and the BigQuery history stays until its tables expire.
What it costs
Security Command Center Standard is free. Pub/Sub and BigQuery charge by volume, which findings keep small.
Terraform. Cloud Guard with Oracle's detector recipes, and an email on each problem
What you need first
- A tenancy administrator, since Cloud Guard is switched on for the whole tenancy.
- A reporting region, usually the home region. It cannot be changed once set.
What it creates
- The policy Oracle documents for Cloud Guard to read what it checks
- Cloud Guard switched on, with a target on the root compartment and Oracle's configuration and activity detector recipes
- An email for every problem Cloud Guard finds
- Oracle's threat detector recipe as well, email only at the risk levels you pick, and an email for every dismissed problem (Standard)
See the two alerts this creates
The code
Quick startReady
tenancy_ocid = "ocid1.tenancy.oc1..change-me"main.tf, line 21reporting_region = "us-ashburn-1"main.tf, line 22alert_email = "security-alerts@example.com"main.tf, line 23
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open main.tf as plain text
StandardReady
tenancy_ocid. The tenancy. Cloud Guard watches it from the root compartment down.region. The reporting region, such as us-ashburn-1. Cloud Guard keeps findings and sends events here, and it cannot be changed once set.alert_email. Address for the alerts. It must confirm the subscription before mail arrives.
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.# terraform.tfvars tenancy_ocid = "" region = "" alert_email = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
tenancy_ocid. The tenancy. Cloud Guard watches it from the root compartment down.region. The reporting region, such as us-ashburn-1. Cloud Guard keeps findings and sends events here, and it cannot be changed once set.alert_email. Address for the alerts. It must confirm the subscription before mail arrives.
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.# terraform.tfvars tenancy_ocid = "" region = "" alert_email = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Make a bucket public in a test compartment. A problem appears in Cloud Guard when the configuration detector next scans, and the email follows. Standard prints more checks with terraform output verify.
A compartment takes one Cloud Guard target. If Cloud Guard was switched on in the console with a target on the root, apply fails until you import it or remove it.
Cloud Guard sends its events in the reporting region only, so the email rule lives there whatever region the resources are in.
Each address must confirm its Notifications subscription before any email arrives.
Cloud Guard reports; it does not refuse. The guardrail template is where refusals belong.
How to undo it
terraform destroy removes the rules, the target, and the policy, and switches Cloud Guard off.
What it costs
Nothing. Cloud Guard is free; Notifications email is free up to a monthly limit.
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.