Skip to main content

Policy Examples

Copy these tested policy configurations into your governing policy directory and adapt the parameters to your environment. For individually reusable policies, use the Policy Library.

Usage​

The bundles below demonstrate combinations of policies. The library provides one policy per entry, with its own parameters and test cases. Each library entry has CEL and Starlark tabs containing complete, interchangeable manifests tested against the same inputs. Choose one implementation; do not install both versions of a policy.

Save a document below as a .yaml file in your policy directory, then set:

export ATMOS_POLICY_DIR="$PWD/policy.d"

Every rule in that directory is loaded. Remove unwanted rules before enabling a document. For CI, use a protected governing directory.

Terraform resource controls​

RuleDenies whenParameter defaults
protect-stateful-resourcesA protected resource is deleted or replacedtypes: RDS instance/cluster, S3 bucket
create-before-destroyA replacement destroys before creatingNone
limit-change-countMore than the maximum managed resources changemaximum: 10
disallow-resource-typesA forbidden resource exists after the changetypes: IAM users and access keys
allowed-instance-typesAn EC2 instance type is absent, unknown, or outside the allowlistallowed: [t3.micro, t3.small]
require-owner-tagA planned EC2 instance lacks a known, nonempty Owner tagNone
examples/policies/terraform/policy.yaml

Run with Terraform saved-plan commands. Deleting a disallowed resource is permitted by the resource-type rule; deleting a resource protected by another rule still blocks.

GitHub event check​

RuleDenies whenRequired input
reject-fork-planThe PR head and base repositories differComplete GitHub Actions event
examples/policies/github/policy.yaml

Missing required CI context blocks the command, including local invocations. This is a plan-time check, not protection against running untrusted code before planning. See CI Context.

Lifecycle hooks and operation controls​

RuleSelectionEffect
lint-successful-planSuccessful Terraform planRequire TFLint
scan-productionBefore Terraform plan in a prod- stackRequire Checkov
callback-after-applySuccessful Helm applyRequire HTTP callback
cleanup-failed-applyFailed Kubernetes applyRequire cleanup command
deny-production-deleteBefore Helm delete in a prod- stackDeny

Replace the callback URL and cleanup executable. Install the tools or add approved version pins under spec.tools. All selected hooks in this example must execute and succeed.

examples/policies/lifecycle/policy.yaml

See Hooks for skip protection, ordering, retries, and post-apply failure semantics.