Sign in
Menu
Sign up
Docs
Check before apply

Compliance.tf provider for AWS

registry.compliance.tf/compliancetf/aws is the AWS provider for Terraform and OpenTofu with compliance controls built in. It runs the official hashicorp/aws provider unmodified and checks the aws_* resource types its controls cover against signed controls before Terraform calls AWS. A resource that breaks a control gives a warning or, in hard_fail mode, fails the plan, with the control id, the setting to change and a link to the control's page.

This page is for platform leads who own the Terraform standards and are deciding whether to adopt the provider. To try it on one configuration, follow the Quickstart.

Where the compliance.tf provider acts Terraform sends each resource request to compliancetf/aws, which checks it against the built-in CIS controls, reports a violation as a warning or error, writes an evidence record for every check, and forwards requests that are not denied to the unmodified hashicorp/aws provider, which calls AWS. each resource signed controls violation every check if not denied Terraform or OpenTofuplan, apply, refresh, import Built-in CIS controlssigned bundle, verified at load compliancetf/awschecks the resource Warning or errorcontrol id, fix, docs link hashicorp/awsunmodified, same version Evidence recordcompliancetf/evidence AWScreates or changes the resource

The problem

Compliance.tf modules carry their controls inside the module. A resource written by hand in a root module, such as an aws_db_instance or an aws_security_group, does not go through a module, so no module control sees it. Scanners can report it, but each pipeline wires its own scanner, and a finding that only shows in a CI report is easy to merge past.

The provider puts the check in the step every run already has: the AWS provider. The check runs wherever Terraform runs, on a laptop or in CI, with no extra pipeline step.

Who it helps

WhoWhat they get
Platform leads who own Terraform and OpenTofu standardsa source-line change with the same version numbers, a default that only warns, and one setting to make violations fail the plan
Application engineers who write the Terraforma plan-time message that names the control, the line and the value to set
Security engineers who own the controlsa list of the controls and resource types it checks, a statement of what it does not check, and a local record of every check

Where it acts

  • Plan. Terraform asks the provider to plan each resource. The provider checks the planned values against every control for that resource type, then passes the request to hashicorp/aws.
  • Before apply. The provider checks the resource again before it forwards the apply to hashicorp/aws. A value that was unknown at plan is checked here. After apply, it checks the result again.
  • Refresh and import. The provider checks what it reads back and warns on a violation.

A violated control warns or, in hard_fail mode, fails the run; an existing resource with no planned change only warns. The provider never changes a value you wrote. compliancetf/aws X.Y.Z runs hashicorp/aws X.Y.Z, so the resources and arguments stay the same. Roll out and run in CI covers the modes.

The provider checks resources in the root module, and in child modules that themselves require registry.compliance.tf/compliancetf/aws. Every terraform-aws-modules module requires hashicorp/aws, so its resources are not checked. Which modules are checked explains why and lists the options.

Status

Available means it ships in the current release and is supported. Not available means it needs a signed organization profile, and compliance.tf does not issue them.

CapabilityStatus
Built-in CIS baseline: controls on encryption, public access, backup retention, deletion protection, and SSH and RDP ingress (list)available
soft_fail (default) and hard_fail modes, in the compliance {} block or COMPLIANCETF_ENFORCEMENT_MODEavailable
Checks at plan, before apply, on refresh and on importavailable
Local, hash-chained evidence records of every checkavailable
A signed bundle archive for air-gapped runs (control_bundle_path)available
Organization mode: organization profiles, mode floors, exceptions, exception grants, grandfather baselinesnot available

Leave org_id, COMPLIANCETF_ORG_ID and COMPLIANCETF_TOKEN unset: setting them makes deny controls fail the plan or stops every plan. The details are on the Reference page.

What it is not

  • It does not make you compliant with CIS or any other framework. It checks the controls it has, on the resources Terraform manages through it.
  • It does not replace continuous detection. Keep AWS Config, Security Hub or your scanner for resources Terraform does not manage, or that change outside Terraform. It sees a resource only when Terraform plans, applies, refreshes or imports it.
  • It checks settings on one resource at a time, not how resources fit together.
  • It cannot stop someone who edits the configuration from changing the provider source or the mode. Protect those lines in code review.

What it contacts

  • terraform init downloads the provider from registry.compliance.tf. Release archives are signed with the compliance.tf release key, which Terraform checks at init.
  • At run time the provider downloads hashicorp/aws from releases.hashicorp.com only when no verified copy is cached, and checks the HashiCorp signature and the pinned checksum before it starts the binary.
  • With org_id and COMPLIANCETF_ORG_ID unset, it does not contact compliance.tf at run time. It never sends your configuration, state or AWS credentials to compliance.tf.

Get the provider

The provider is free, needs no account or token, and is licensed under the Mozilla Public License 2.0, the same license as hashicorp/aws. It is tested with Terraform 1.5 and later and with OpenTofu. The source, releases and issue tracker are on GitHub.

Source code and internals

To review the provider's code before you adopt it, start with the architecture notes in the provider repository:

DocumentWhat it covers
ArchitectureThe request flow, how hashicorp/aws and the control bundles are verified, the caches and the evidence record format. Each topic names the code
Provider referenceThe exact settings, variables and limits of a release. On GitHub, switch from master to the tag of the provider version in your lock file
PerformanceStartup cost, what the caches save, and how to reproduce the measurements
CHANGELOG and releasesWhat changed in each version, and the signed release archives

Bugs, questions and feature requests go to GitHub issues. Report a security problem privately through GitHub security advisories.

Pages in this section

  • Quickstart: switch one configuration from hashicorp/aws, see a finding, and switch back.
  • Roll out and run in CI: modes, CI jobs, reading findings, evidence and caches.
  • Which modules are checked: the root module, child modules, and what to do with terraform-aws-modules.
  • Reference: every setting, environment variable, CIS control and limitation.

On this page

Ask AI about this

Help improve this page