IaC compliance scanning
Checkov and Open Policy Agent are nearly even for scanning infrastructure-as-code and container configurations before deployment.
It depends
For baking compliance checks into service creation templates without slowing developers, Wiz is recommended most.
Since Sep 24Updated Nov 15, 2026Based on 35 AI answers
Reviewed by Dimitry Apollonsky
Brands AI mentions
Scanning infrastructure-as-code and container configurations before deployment
Also mentioned rarely: HashiCorp Sentinel, GitHub Actions, GitLab CI, AWS, AWS CloudFormation, TFLint, Azure Bicep, Gitlab, Kubernetes, OpenTofu, pre-commit, AWS Config, Azure Policy, cfn-lint, Helm, Jenkins, Aqua Security, AWS Security Hub, Bitbucket Cloud, Visual Studio Code, GitHub, JetBrains, Kyverno, Open Policy Agent Gatekeeper, Pulumi, Terraform Cloud, Microsoft Azure, Google Cloud, HashiCorp, HashiCorp Terraform, National Institute of Standards and Technology (NIST), Prisma Cloud, Terrascan · runterrascan.io, Wiz, AWS Organizations, Amazon GuardDuty, Microsoft Defender for Cloud, Azure DevOps, Azure Resource Manager, Azure Resource Manager (ARM) templates, Bitbucket, Bridgecrew, Checkmarx, Checkov VS Code Extension, Center for Internet Security (CIS), Google Cloud Organization Policy Service, DefectDojo, Terraform Policy, Dockerfiles, Snyk Docs, GitGuardian, Kubeconform, Trivy Action, Gitleaks, OWASP IaC Security Cheat Sheet, Oxygen Forensics Detective, Google Search, Semgrep, Snyk, SonarQube for IDE, Tenable Cloud Security, TerraScan · terrasolid.com, Inspector, Wiz Code, yamllint
- CheckovChatGPTChatGPT 83%Google AI ModeGoogle AI Mode 100%
- Open Policy AgentChatGPTChatGPT 89%Google AI ModeGoogle AI Mode 94%
- TrivyChatGPTChatGPT 61%Google AI ModeGoogle AI Mode 59%
- TerraformChatGPTChatGPT 78%Google AI ModeGoogle AI Mode 29%
- ConftestChatGPTChatGPT 39%Google AI ModeGoogle AI Mode 41%
Questions and answers
Google AI ModeNov 10, 2026
Implementing pre-deployment compliance checks for Infrastructure as Code (IaC)—such as Terraform, OpenTofu, Bicep, or CloudFormation—relies on a "shift-left" philosophy. Catching misconfigurations and regulatory gaps before code hits production saves remediation costs and stops insecure resources from ever spinning up.
Recommended Layers of Defense
To build a robust pipeline, implement scanning across multiple stages of the developer workflow rather than relying on a single gate at the end:
- Local Pre-Commit Hooks (Developer Workstation)
- What it does: Runs fast, lightweight static analysis before code is even committed to version control.
- Goal: Immediate feedback loop so developers catch syntax errors, exposed secrets, or glaring security anti-patterns (e.g., public S3 buckets) on their own machine.
- Common Tools:
pre-commitframework paired with hooks likecheckov,tfsec, ortrivy.
- Pull Request (PR) / Merge Request Scans (CI/CD Pipeline)
- What it does: Automatically triggers deep static analysis and policy-as-code evaluations whenever a PR is opened or updated.
- Goal: Block merges if high-severity compliance violations (e.g., CIS Benchmarks, HIPAA, SOC 2) are detected, posting line-by-line feedback directly onto the pull request.
- Common Tools: Tenable Cloud Security,
Checkovby Bridgecrew,KICS(Keeping Infrastructure as Code Secure),Trivyby Aqua Security, ortfsec.
- Policy-as-Code Frameworks (Governance & Logic)
- What it does: Enforces custom organizational rules (e.g., "all EC2 instances must have an
Ownertag" or "RDS databases must use customer-managed KMS keys") using a dedicated policy language. - Goal: Move beyond out-of-the-box security rules into company-specific architectural governance.
- Common Tools:
Regovia Open Policy Agent (OPA) / Conftest, or HashiCorpSentinel(if using Terraform Enterprise/Cloud).
- What it does: Enforces custom organizational rules (e.g., "all EC2 instances must have an
- Plan-Time & Dry-Run Evaluation (State/Provider Context)
- What it does: Evaluates the execution plan (e.g.,
terraform planoutput) rather than just the raw source code. - Goal: Catch issues that only become apparent when variables, modules, and state references resolve (e.g., understanding whether a subnet resolves to a public or private route table).
- What it does: Evaluates the execution plan (e.g.,
Key Strategy Best Practices
- Fail Fast, Provide Context: If a scan fails a PR, don’t just output a generic "Compliance Violation: CIS 3.1." Link the failure directly to remediation steps or docs so the developer knows how to fix it.
- Tier Your Severity Levels:
- Critical / Blockers: Open/unencrypted storage, open security groups (0.0.0.0/0 on SSH/RDP), hardcoded secrets. (Block PR merge)
- Warnings / High: Missing mandatory tagging, lack of multi-AZ configuration. (Require security override or ticket approval)
- Low / Info: Best practice suggestions. (Informational comment only)
- Adopt Policy-as-Code for Custom Rules: Standard security tools cover CIS and NIST, but every enterprise has unique rules. Writing custom OPA/Rego policies ensures your specific cloud landing zone architecture is enforced programmatically.
- Keep Scans Fast: If a pre-commit or CI scan takes 10+ minutes, developers will try to bypass it. Optimize cache usage and run heavy compliance checks asynchronously or in parallel.
If you'd like to narrow this down, tell me:
- What IaC tool and cloud provider are you primarily using (e.g., Terraform/AWS, Bicep/Azure)?
- Are you looking for open-source tools or commercial enterprise platforms?
ChatGPTNov 10, 2026
The recommended approach is to implement shift-left Infrastructure as Code (IaC) security and compliance scanning: inspect Terraform, CloudFormation, Kubernetes manifests, Helm charts, and other infrastructure definitions before they are merged or deployed.
The goal is to catch misconfigurations, security vulnerabilities, policy violations, exposed secrets, and regulatory compliance issues as early as possible—ideally directly in the developer's IDE or CI/CD pipeline.
I recommend a layered strategy rather than relying on a single scanner.
1. Implement a multi-layer scanning strategy
IaC compliance scanning pipeline
1. Developer writes IaC
Terraform · CloudFormation · Kubernetes · Helm
2. Syntax & lint
Formatting, schema, invalid configurations
3. Security scan
Misconfigurations, insecure defaults, secrets
4. Policy compliance
CIS, NIST, organizational policies
5. Dependency scan
Modules, providers, images, packages
6. CI/CD policy gate
Pass · Fail · Require approval
7. Deploy to cloud
Only approved infrastructure changes proceed
Here is how I would implement each layer.
A. Syntax validation and linting
Catch basic problems before performing security analysis.
Recommended tools:
- Terraform:
terraform fmtandterraform validate. - Kubernetes: kubeconform for schema validation.
- CloudFormation: AWS CloudFormation Linter (
cfn-lint). - YAML: yamllint.
These checks catch malformed configurations, unsupported properties, and structural errors.
B. Security misconfiguration scanning
This is one of the most important layers.
Look for issues such as:
- Publicly accessible storage buckets.
- Security groups allowing unrestricted inbound traffic.
- Unencrypted storage volumes and databases.
- Missing logging and monitoring.
- Overly permissive IAM roles.
- Hardcoded credentials and secrets.
- Missing network segmentation.
- Containers running as root.
Recommended scanners:
Tool Best use Checkov Broad IaC security and compliance scanning Trivy IaC, container, and vulnerability scanning Terrascan Policy-based IaC security analysis KICS Multi-platform infrastructure scanning My starting recommendation would be Checkov or Trivy, depending on your existing security tooling.
C. Policy-as-Code enforcement
Static scanners are useful, but organizations often need custom compliance requirements.
For example:
- All production storage must be encrypted.
- Public IP assignment is prohibited unless explicitly approved.
- All resources must include an owner and environment tag.
- Databases must have automated backups enabled.
- Only approved cloud regions can be used.
Consider:
- Open Policy Agent (OPA) for general-purpose policy enforcement.
- Conftest for testing configuration files against Rego policies.
- HashiCorp Sentinel for Terraform-focused policy enforcement.
This lets your security team maintain policies independently of application code.
D. Scan the Terraform execution plan, not just source files
This is an especially important recommendation if you use Terraform.
Scanning
.tffiles alone can miss problems introduced by:- Variable substitutions.
- Environment-specific configuration.
- Module dependencies.
- Dynamically resolved resource attributes.
- Differences between development and production settings.
A better approach is to scan both the source and the generated Terraform plan.
For example:
bashterraform init terraform validate # Scan source code checkov -d ./terraform # Generate execution plan terraform plan -out=tfplan # Convert plan to JSON terraform show -json tfplan > tfplan.json # Scan actual planned changes checkov -f tfplan.jsonPlan scanning provides additional context about the infrastructure changes being proposed. Treat plan files and their JSON output as sensitive because they can contain secrets or other confidential values.
E. Secret and dependency scanning
Add separate checks for:
- AWS access keys and cloud credentials.
- Private keys and API tokens.
- Vulnerable Terraform providers.
- Third-party Terraform modules.
- Container image vulnerabilities.
- Untrusted or outdated Helm chart dependencies.
Tools such as Trivy can help consolidate configuration, secret, and vulnerability scanning.
2. Integrate the checks into your CI/CD pipeline
I recommend making pull requests the primary compliance enforcement point.
For example, using GitHub Actions and Checkov:
yamlname: IaC Security Scan on: pull_request: branches: - main jobs: iac-security: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Run Terraform validation run: | terraform fmt -check -recursive terraform init -backend=false terraform validate - name: Run Checkov uses: bridgecrewio/checkov-action@v12 with: directory: ./terraform framework: terraform soft_fail: false output_format: cliThis is a starting example; in production, pin third-party actions to verified commit SHAs and use controlled tool versions.
The pipeline should:
- Trigger whenever an IaC pull request is created or updated.
- Validate the IaC syntax.
- Execute security and compliance scans.
- Publish findings as pipeline artifacts or pull-request annotations.
- Fail the pipeline when blocking policy violations are detected.
- Require approval for explicitly permitted exceptions.
AWS also documents a centralized Checkov approach where reusable workflows and custom policies can be shared across multiple repositories.
3. Define compliance policies and severity levels
Avoid treating every scanner finding equally. Establish a consistent severity model.
Severity Example Recommended action Critical Public database containing sensitive data Block deployment High Unrestricted administrative access Block deployment Medium Missing encryption or logging Require remediation or approval Low Missing optional metadata Track and remediate I would also map individual rules to recognized compliance frameworks.
Framework Relevant areas CIS Benchmarks Cloud security configurations NIST 800-53 Access control, auditing, encryption SOC 2 Security, availability, confidentiality PCI DSS Payment infrastructure security ISO 27001 Information security controls The important distinction is that a scanner finding should map to an actual organizational control, not simply exist as an isolated technical warning.
4. Manage exceptions and false positives
A common problem with IaC scanning is that developers eventually ignore findings if too many legitimate configurations are blocked.
Implement an exception management process:
- Require a documented business justification for every exception.
- Assign an owner to each exception.
- Set an expiration date for temporary exceptions.
- Require security approval for critical or high-risk exceptions.
- Track suppressed findings centrally.
- Reevaluate exceptions periodically.
A useful rollout strategy:
- Start in reporting mode to establish a baseline.
- Identify recurring issues and tune policies.
- Enforce blocking on newly introduced critical and high findings.
- Gradually expand enforcement to medium-severity findings.
This avoids blocking development because of thousands of pre-existing findings.
5. Add runtime compliance and drift detection
One limitation of scanning IaC is that it only examines the infrastructure definitions and proposed changes.
For example:
- Your Terraform defines a private S3 bucket.
- Someone manually changes its permissions through the AWS console.
- Your Terraform files still pass every security check.
- Your actual cloud infrastructure is now potentially exposed.
To address this, complement IaC scanning with Cloud Security Posture Management (CSPM).
Examples include:
- AWS Security Hub.
- Microsoft Defender for Cloud.
- Prisma Cloud.
- Wiz.
Also consider Kubernetes admission controls such as OPA Gatekeeper or Kyverno to enforce policies when workloads are deployed.
This creates continuous compliance rather than simply checking compliance before deployment.
6. My recommended technology stack
Here is the combination I would consider for a new implementation:
Requirement Recommended technology IaC static scanning Checkov Additional configuration scanning Trivy Terraform validation Terraform CLI Kubernetes validation kubeconform Custom compliance policies OPA / Conftest Secret scanning Trivy or Gitleaks CI/CD enforcement GitHub Actions / GitLab CI Runtime compliance CSPM platform Compliance reporting SARIF and centralized dashboards Official documentation:
- Checkov
- Trivy IaC scanning
- Terraform plan scanning
- AWS centralized Checkov implementation
- OWASP IaC scanning guidance
7. Suggested implementation roadmap
-
Phase 1 – Establish scanning
Integrate Checkov into CI/CD and scan all existing Terraform, Kubernetes, and CloudFormation repositories.
-
Phase 2 – Establish security standards
Map built-in checks to CIS/NIST requirements and implement organization-specific policies.
-
Phase 3 – Enforce compliance
Introduce pull-request gates, severity-based blocking, and controlled exception management.
-
Phase 4 – Extend coverage
Add Terraform plan scanning, secret scanning, module vulnerability checks, and Kubernetes admission policies.
-
Phase 5 – Continuous compliance
Integrate CSPM, detect configuration drift, and generate compliance evidence for audits.
8. A few important questions about your environment
The optimal implementation depends on your IaC technology and cloud platform.
What IaC technology are you using?
Which cloud platform?
Which CI/CD platform?
What is your primary objective?
[Build my implementation architecture]
With these details, I can provide a concrete reference architecture, including scanner configuration, custom compliance policies, pipeline YAML, and deployment-blocking rules.
Pages cited in this answer7
- checkov.ioTerraform Plan Scanning - checkov
- trivy.devTerraform - Trivy
- learn.microsoft.comConfigure agentless code scanning (Preview) - Microsoft Defender for Cloud | Microsoft Learn
- github.comDevSecOpsGuideline/current-version/2-Process/2-3-Build/2-3-4-Infrastructure-as-Code-Security/2-3-4-1-Infrastructure-as-Code-Scanning.md at master · OWASP/DevSecOpsGuideline · GitHub
- docs.aws.amazon.comImplement centralized custom Checkov scanning to enforce policy before deploying AWS infrastructure - AWS Prescriptive Guidance
- owasp.github.ioInfrastructure as Code (IaC) Scanning - OWASP DevSecOps Guideline
- checkov.iocheckov
- Local Pre-Commit Hooks (Developer Workstation)
Google AI ModeOct 4, 2026
Implementing compliance checks for Infrastructure as a Code (IaC) files before deployment—often referred to as Shift-Left Security —helps catch misconfigurations, security vulnerabilities, and policy violations early in the development lifecycle.
Here are the recommended best practices to build a robust IaC compliance pipeline:
- Shift Left by Integrating Early : Run checks as early as possible. Inject linting and static analysis into developer IDEs (via pre-commit hooks or extensions) so developers catch syntax and compliance errors before even pushing code to version control.
- Automate Checks in CI/CD Pipelines : Gate your pull requests and merge requests with automated security scans. If a policy violation or critical misconfiguration is detected, automatically block the merge or deployment until it is resolved.
- Treat Policies as Code : Define your compliance and security rules using code (using frameworks like Open Policy Agent/Rego or tool-native policy languages) rather than manual checklists. This ensures version control, peer reviews, and automated testing for your compliance rules themselves.
- Implement Continuous Monitoring and Drift Detection : Static analysis before deployment isn't enough. Continuously scan deployed cloud environments to detect configuration drift or manual changes that violate your baseline compliance policies.
- Provide Actionable Developer Feedback : Don't just fail a pipeline with a cryptic error code. Ensure your scanning tools point directly to the offending file, line number, and rule violation, while offering remediation advice or links to internal security docs.
- Adopt Risk-Based Prioritization : Not all misconfigurations carry the same risk. Configure your tools to differentiate between critical vulnerabilities (e.g., public S3 buckets with sensitive data) and low-risk stylistic warnings so developers aren't overwhelmed by alert fatigue.
- Leverage Industry Standards and Baselines : Map your custom or built-in rules to recognized frameworks like CIS Benchmarks, NIST, PCI-DSS, or SOC2 to streamline auditing and reporting for compliance teams.
Would you like me to recommend specific IaC scanning tools (like Checkov, tfsec, or OPA) or help you design a sample CI/CD integration workflow?
ChatGPTOct 4, 2026
Yes. The strongest pattern is to treat IaC compliance as a pre-deployment policy gate, not merely as a static scan. The goal is to prove that the planned infrastructure is compliant before an
apply/deployment can happen, while also continuously checking the deployed environment for drift.Recommended architecture
Developer │ ├── IaC lint / format / validation ├── Secret scanning ├── IaC security scanner │ └── Checkov / Trivy / equivalent ├── Dependency & supply-chain checks │ └── pinned providers/modules, trusted registries │ ▼ Pull Request │ ├── Policy-as-code │ └── OPA/Rego, Sentinel, etc. ├── Terraform plan / rendered manifest │ ▼ Compliance Gate │ ├── FAIL → block merge/deployment └── PASS │ ▼ Human approval │ ▼ Apply/Deploy │ ▼ Runtime compliance + drift detectionOWASP specifically recommends integrating IaC security checks into the SDLC/CI pipeline, combining static analysis, secret detection, least privilege, artifact integrity, and continuous monitoring rather than relying on a single scanner.
1. Define compliance as code
Don't encode requirements only in documentation such as "S3 buckets must be private." Turn them into executable policies.
Examples:
- No public storage buckets.
- No
0.0.0.0/0ingress to administrative ports. - Encryption required for data stores.
- Logging enabled.
- Required tags:
owner,environment,data_classification. - Only approved regions.
- Only approved instance/resource types.
- IAM permissions must follow least privilege.
- Terraform providers/modules must be pinned.
- Modules must come from approved registries.
- Certain resource types require security approval.
This is the fundamental policy-as-code model. HashiCorp currently supports Sentinel and OPA for this purpose, and describes policy enforcement as something that can either warn or prevent provisioning.
For example, conceptually:
regopackage terraform.security deny[msg] { resource := input.resource_changes[_] resource.type == "aws_security_group_rule" resource.change.after.cidr_blocks[_] == "0.0.0.0/0" resource.change.after.from_port <= 22 resource.change.after.to_port >= 22 msg := "SSH must not be exposed to the public internet" }The important part isn't the particular language; it's that the rule is version-controlled, tested, reviewed, and automatically enforced.
2. Scan both the source and the resulting plan
This distinction is important.
Source-level checks
Inspect the actual IaC:
- Terraform
- CloudFormation
- Kubernetes YAML
- Helm
- ARM/Bicep
- Pulumi
- Dockerfiles, etc.
Tools such as Trivy provide IaC misconfiguration scanning across Terraform, Kubernetes, CloudFormation and other formats.
Plan-level checks
For Terraform, also inspect:
terraform plan ↓ machine-readable plan ↓ policy engine ↓ allow / denyThis catches problems that aren't always obvious from individual
.tffiles because variables, modules, defaults and expressions can change the final resource configuration.For compliance, the plan should be the authoritative pre-deployment object.
HashiCorp's policy frameworks can evaluate Terraform plan/configuration data and enforce policies as part of the Terraform workflow.
3. Separate generic security scanning from organizational policy
I'd use at least two layers.
Layer Purpose Examples IaC scanner Known security misconfigurations Checkov, Trivy Policy engine Your organization's rules OPA, Sentinel Compliance baseline Regulatory/security framework CIS, NIST, PCI, etc. Secrets scanner Credentials accidentally committed secret scanning tools Dependency checks Provider/module/image risk dependency/SBOM tooling Runtime scanner What actually exists cloud posture/configuration tools Don't try to make one tool do everything.
For example, CIS provides cloud-specific configuration benchmarks for AWS, Azure, GCP, Kubernetes and others; these make a useful source for baseline controls.
4. Make severity and enforcement explicit
A common mistake is treating every violation identically.
I'd define something like:
Severity Example Action Critical Public database, exposed credentials Hard fail High Public SSH/RDP, excessive IAM Hard fail Medium Missing encryption/tag Usually fail Low Naming/documentation issue Warning Advisory Recommended optimization Report only You can also introduce an exception mechanism, but exceptions should themselves be controlled artifacts:
yamlexception: policy: public-load-balancer resource: module.foo.aws_lb.main reason: "Public ingress is required for customer API" owner: security-team expires: 2026-12-31 approved_by: security@exampleNever allow developers to simply add something like:
yamlskip: truewithout an auditable reason, owner and expiration.
HashiCorp's Sentinel model is useful here: it supports advisory, soft-mandatory and hard-mandatory enforcement levels, with overrides recorded for non-hard policies.
5. Put the gate before production, not after
A strong deployment rule is:
No compliant plan → no production apply.
For example:
PR │ ├─ syntax/format ────────────────┐ ├─ secret scan ──────────────────┤ ├─ IaC security scan ────────────┤ ├─ dependency/module checks ─────┤ ├─ terraform plan ───────────────┤ ├─ policy-as-code ───────────────┤ └─ compliance mapping ───────────┘ │ ALL REQUIRED PASS │ ▼ Human approval │ ▼ APPLYThis is preferable to deploying first and having a CSPM tool tell you afterward that the infrastructure violates policy.
OWASP likewise recommends automated IaC checks in CI/CD and manual review/approval for production deployment.
6. Lock down the IaC supply chain
This is frequently overlooked.
For Terraform specifically, I would require:
- Exact/pinned provider versions.
- Pinned module versions.
- Approved module registries.
- No arbitrary Git branches as module sources.
- Controlled provider sources.
- Review of changes to shared modules.
- Version-controlled policy libraries.
- Protected CI/CD configuration.
- Short-lived CI cloud credentials.
- No cloud access keys embedded in repositories.
HashiCorp explicitly recommends pinning providers/modules and controlling module sources as global policy guardrails.
OWASP also highlights IaC repositories, pipelines and state files as high-value attack surfaces and recommends narrowly scoped CI permissions and short-lived/federated credentials.
7. Build secure "golden modules"
Don't make every developer solve security from scratch.
Instead of:
hclresource "aws_s3_bucket" "app" { bucket = var.name }provide something like:
hclmodule "app_bucket" { source = "company-registry/storage/aws" version = "3.2.1" name = var.name encryption_enabled = true public_access_block = true access_logging = true }The module should implement your organization's secure defaults.
This gives you two complementary controls:
Prevent bad configurations
→ policy-as-code
Make good configurations easy
→ approved/golden modules
That combination is considerably more scalable than trying to write thousands of individual policies.
8. Map every policy to an actual requirement
Don't build a giant collection of arbitrary scanner rules.
Maintain a control catalog:
CTRL-IAM-001 Requirement: IAM follows least privilege Source: Internal Security Standard IaC rule: iam_no_wildcard_permissions Severity: Critical Enforcement: Block Owner: Security Engineering CTRL-NET-004 Requirement: Administrative ports aren't internet accessible Source: CIS / Internal Standard IaC rule: no_public_admin_ingress Severity: Critical Enforcement: BlockThis makes the system auditable.
When an auditor asks:
"How do you enforce requirement X?"
you can show:
Requirement ↓ Control ↓ Policy ↓ Automated test ↓ CI result ↓ Deployment decision
9. Test the policies themselves
Your compliance engine is now production-critical software.
Therefore:
Policy ├── positive test → compliant infrastructure passes ├── negative test → violating infrastructure fails ├── edge cases └── regression testsFor example:
test_public_s3_bucket_denied test_private_s3_bucket_allowed test_bucket_with_exception_allowed test_expired_exception_deniedHashiCorp explicitly recommends testing policies, keeping them in version control, and using CI to regression-test policy changes.
10. Don't stop at deployment
Pre-deployment compliance answers:
"Was this change compliant when we approved it?"
It doesn't answer:
"Is the environment still compliant?"
You therefore want:
IaC │ ├── pre-deployment compliance │ ▼ Cloud │ ├── runtime configuration scan ├── drift detection ├── continuous compliance └── security monitoringThis catches:
- Console changes.
- Compromised credentials.
- Drift.
- Provider-side configuration changes.
- Resources created outside IaC.
- Misconfigurations introduced by other automation.
OWASP recommends inventory, logging, monitoring and continuous runtime analysis in addition to IaC controls.
A practical baseline I'd implement
If you're building this from scratch, I'd start with five gates:
Gate 1 — Syntax & quality
format validate lint module/provider version checksGate 2 — Security
IaC misconfiguration scanner secret scanner dependency/provider/module checksGate 3 — Compliance
terraform plan ↓ OPA/Sentinel ↓ organization policies ↓ CIS/NIST/regulatory controlsGate 4 — Change risk
Calculate risk from things such as:
+ production + IAM change + network perimeter change + encryption change + public exposure + data classification + destructive operationHigh-risk changes require additional approval.
Gate 5 — Runtime
continuous cloud posture scan + drift detection + alert/remediationMy recommended technology split
For a Terraform-heavy environment, a sensible architecture would be:
Trivy or Checkov → broad IaC security/misconfiguration detection
OPA/Rego → organization-specific, portable policy-as-code
Sentinel → particularly attractive if you're standardized on HCP Terraform
CIS Benchmarks → baseline controls
Secret scanner → credentials/secrets
Cloud posture/runtime scanner → validate actual deployed stateHashiCorp currently supports both Sentinel and OPA, while noting that organizations already standardized on OPA can use their existing policies.
The key architectural principle is defense in depth: scanner ≠ compliance engine ≠ runtime monitoring. You want all three.
If you tell me whether you're using Terraform, CloudFormation, Pulumi, Kubernetes, or a mix, I can also lay out a concrete CI/CD reference implementation (including the policy repository structure, OPA/Sentinel rules, severity model, exception workflow, and PR/deployment gates).
Pages cited in this answer8
- cheatsheetseries.owasp.orgInfrastructure as Code Security - OWASP Cheat Sheet Series
- developer.hashicorp.comDefine policies overview | Terraform | HashiCorp Developer
- trivy.devOverview - Trivy
- developer.hashicorp.comPolicy as Code - Sentinel | Validated Designs | HashiCorp Developer
- learn.cisecurity.orgCIS Benchmarks
- developer.hashicorp.comEnforce a policy | Terraform | HashiCorp Developer
- developer.hashicorp.comPolicy as code and Sentinel management | Validated Designs | HashiCorp Developer
- scs.owasp.orgPart 6: Checklists and Operations - OWASP Smart Contract Security
ChatGPTOct 11, 2026
Recommended IaC compliance scanning workflow
Before pushing Infrastructure as Code (IaC) to the cloud, the best practice is to scan locally, enforce security policies in CI/CD, and block deployments when critical compliance checks fail.
This applies to Terraform, AWS CloudFormation, Azure Bicep/ARM, Kubernetes YAML, Helm charts, and similar infrastructure definitions. NIST guidance recommends scanning IaC before it is merged or deployed, with automated checks and traceable remediation.
1. Follow these steps before pushing
Step 1 — Identify your IaC files
Inventory your Terraform (
.tf), CloudFormation, Bicep, Kubernetes, Helm, and related configuration files. Include reusable modules, environment-specific variables, and deployment templates.
Step 2 — Run a static security scan
Detect insecure configurations before they become cloud resources, such as public storage, unrestricted network access, unencrypted data, excessive permissions, and missing logging.
Step 3 — Validate compliance requirements
Map your findings to the controls your organization actually needs, such as CIS Benchmarks, NIST controls, PCI DSS, or internal security standards. Add custom policy-as-code rules for requirements that generic scanners do not cover.
Step 4 — Scan for secrets and other risks
Check for exposed API keys, passwords, private keys, unsafe dependencies, and vulnerable modules. A configuration scan alone may not cover all these risks.
Step 5 — Review, fix, and gate the push
Fix critical and high-severity findings, review any exceptions, and rerun the scan. Run the same checks in pull requests and make required checks block merging when policy violations remain.
Step 6 — Verify the deployment and monitor drift
Where supported, scan a generated Terraform plan or equivalent deployment artifact. After deployment, monitor the live environment for configuration drift and violations that source-code scanning cannot detect.
These steps align with NIST's DevSecOps practices for pre-commit scanning, automated IaC analysis, remediation, and controlled code merging.
2. Choose an IaC scanning tool
These are strong starting points for a practical scanning workflow.
Trivy
Best for a straightforward, multi-purpose security scanner. Checks Terraform, CloudFormation, Kubernetes and Helm, with separate options for secret scanning and custom rules.
Start here if you want a simple CLI workflow.
Checkov
Best for teams that want broad IaC support, built-in checks, custom compliance policies, and CI/CD integration.
Open Policy Agent (OPA) with Conftest
Best for enforcing organization-specific rules, such as approved regions, required encryption, mandatory tags, or restrictions on public network access.
My recommendation: Start with Trivy or Checkov rather than running several overlapping scanners immediately. Add OPA/Conftest if you need custom policy enforcement.
3. Run a scan locally
For a Terraform repository, Trivy provides a quick way to get started.
Install Trivy using its official installation instructions, then run these commands from your repository root.
A. Scan for IaC misconfigurations
bashtrivy config .
B. Scan for exposed secrets and misconfigurations
bashtrivy fs --scanners secret,misconfig .
C. Save findings as a JSON report
bashtrivy config --format json --output iac-report.json .[Copy commands]
These commands follow the official Trivy workflow. Note that the first and second commands cover different scan modes, and the JSON report is useful for the configuration scan.
4. Define your compliance gates
Before adding the scanner to your pipeline, establish rules for what can pass.
Check Recommended action Critical security issue Block the merge or deployment High-severity issue Block by default, with a documented exception process Medium/low findings Track, prioritize, and remediate according to policy Exposed credentials Block and rotate/revoke affected credentials Compliance violation Block if it violates a mandatory control Accepted exception Record the reason, owner, scope, and expiration Also make sure that:
- Exceptions cannot silently disable future checks.
- The scanner and its policy rules are version-controlled or pinned to reviewed versions.
- Pull requests include scan results and remediation details.
- CI jobs produce retained reports for audit evidence.
For a centralized approach to custom checks, AWS provides an example of reusable Checkov scanning workflows and shared policies. AWS Prescriptive Guidance.
5. Tailor the workflow to your environment
I can give you exact commands and a ready-to-use pipeline configuration for your repository. Which IaC technology are you using?
IaC technology
Terraform / OpenTofu
AWS CloudFormation
Azure Bicep / ARM
Kubernetes / Helm
Multiple formats
CI/CD platform
GitHub Actions
GitLab CI
Azure DevOps
Jenkins
Local CLI only
Compliance target
CIS Benchmarks
NIST
PCI DSS
Internal security policies
General cloud security
When should scanning run?
Before commit or push
On every pull request
Both locally and in CI/CD
[Build my scanning workflow]
Pages cited in this answer9
- pages.nist.gov5.1. Functional Demonstration Scenarios — Secure Software Development, Security, and Operations (DevSecOps) Practices documentation
- csrc.nist.govSP 800-204C, Implementation of DevSecOps for a Microservices-based Application with Service Mesh | CSRC
- csrc.nist.ripImplementation of DevSecOps for a Microservices-based Application with Service Mesh
- trivy.devTerraform scanning - Trivy
- checkov.iocheckov
- openpolicyagent.orgOpen Policy Agent - Homepage | Open Policy Agent
- conftest.devConftest
- trivy.devofficial installation guide
- docs.aws.amazon.comImplement centralized custom Checkov scanning to enforce policy before deploying AWS infrastructure - AWS Prescriptive Guidance
Google AI ModeOct 11, 2026
Scanning your Infrastructure as Code (IaC) files before deployment—commonly known as Shift-Left Security —helps catch misconfigurations, compliance violations, and security vulnerabilities early in the development lifecycle.
Here are the recommended steps to implement an effective IaC scanning workflow:
- 1. Select an IaC scanning tool
Choose a tool that supports your specific IaC frameworks (Terraform, CloudFormation, Kubernetes manifests, ARM templates, Ansible, etc.). Popular options include:- Checkov : Open-source, highly popular for Terraform, Kubernetes, and CloudFormation with thousands of built-in compliance policies (SOC2, HIPAA, PCI-DSS).
- Tfsec or Trivy : Fast, developer-friendly scanners by Aqua Security tailored for Terraform and broader infrastructure scanning.
- KICS : Maintaining open-source scanning across multiple IaC platforms (Keeping Infrastructure as Code Secure).
- tf-constructive / cfn-lint : Specialized linters for specific cloud templates.
- 2. Define your compliance and security policies
Map your organization's regulatory and internal security requirements (e.g., encryption at rest, public S3 bucket prevention, mandatory resource tagging) to the scanner. Most tools allow you to use pre-built compliance frameworks or write custom policies using languages like Rego (via Open Policy Agent) or Python/YAML custom checks. - 3. Integrate scanning into local development (Pre-commit)
Install the scanning tool locally or configure a pre-commit hook so developers can scan their code before even committing it to version control. This provides instant feedback and saves time. - 4. Automate scans in CI/CD pipelines
Integrate the scanner into your Continuous Integration pipeline (GitHub Actions, GitLab CI, Bitbucket Pipelines) on every Pull Request or Merge Request. Configure the pipeline to block merges or flag alerts if critical or high-severity misconfigurations are detected. - 5. Implement policy-as-code enforcement at deployment (Gatekeeping)
Add a final gatekeeping layer right before provisioning using tools like Open Policy Agent (OPA) or HashiCorp Sentinel embedded within your CI/CD or Terraform Cloud/Enterprise environment to ensure unverified code cannot be applied to cloud infrastructure. - 6. Review, remediate, and tune rules
Establish a feedback loop to review false positives, adjust baseline policies, and guide developers on how to remediate flagged issues using automated fix suggestions or documentation links provided by the scanning tools.
Would you like assistance with:
- Setting up Checkov or Trivy in a specific CI/CD pipeline?
- Writing custom compliance policies for your team?
- Choosing a tool based on your specific IaC stack (e.g., Terraform vs. Kubernetes)?
How can we enforce security standards without slowing down devs? What platform allows us to bake compliance checks into the service creation templates?
Summary
Wiz is the usual answer for baking compliance checks into service creation templates without slowing developers.
For agents: this page as Markdown, https://parse.gl/topics/iac-compliance-scanning.md. JSON, MCP · free to read, $0.01 a check
This page
Read and search
Connect
An agent can save work before signup: POST https://agent.parse.gl/v1/workspaces
What it costs
Prices: https://parse.gl/pricing.md
Map of the site: https://parse.gl/llms.txt