IaC compliance scanning

and 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, is recommended most.

Since Sep 24Updated Nov 15, 2026Based on 35 AI answersReviewed by

How we measure

Brands AI mentions

Mentioned in, on ChatGPT and Google AI Mode
  • 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

    1. 1Terraform
    2. 2OpenTofu
    3. 3pre-commit
    4. 4Checkov
    5. 5Tfsec
    6. 6Trivy
    7. 7Tenable Cloud Security
    8. 8KICS
    9. 9Aqua Security
    10. 10Open Policy Agent
    11. 11Conftest
    12. 12AWS
    13. 13Azure Bicep
    14. 14HashiCorp Terraform

    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:

    1. 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-commit framework paired with hooks like checkov, tfsec , or trivy.
    2. 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, Checkov by Bridgecrew, KICS (Keeping Infrastructure as Code Secure), Trivy by Aqua Security, or tfsec.
    3. Policy-as-Code Frameworks (Governance & Logic)
      • What it does: Enforces custom organizational rules (e.g., "all EC2 instances must have an Owner tag" 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: Rego via Open Policy Agent (OPA) / Conftest, or HashiCorp Sentinel (if using Terraform Enterprise/Cloud).
    4. Plan-Time & Dry-Run Evaluation (State/Provider Context)
      • What it does: Evaluates the execution plan (e.g., terraform plan output) 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).

    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

    1. 1Terraform
    2. 2Kubeconform
    3. 3cfn-lint
    4. 4yamllint
    5. 5Checkov
    6. 6Trivy
    7. 7TerraScan
    8. 8KICS
    9. 9Open Policy Agent
    10. 10Conftest
    11. 11HashiCorp Sentinel
    12. 12GitHub Actions
    13. 13AWS Security Hub
    14. 14Microsoft Defender for Cloud
    15. 15Prisma Cloud
    16. 16Wiz
    17. 17Kyverno
    18. 18Gitleaks
    19. 19GitLab CI
    20. 20Open Policy Agent Gatekeeper

    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 fmt and terraform 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:

    ToolBest use
    CheckovBroad IaC security and compliance scanning
    TrivyIaC, container, and vulnerability scanning
    TerrascanPolicy-based IaC security analysis
    KICSMulti-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 .tf files 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:

    bash
    terraform 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.json

    Plan 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:

    yaml
    name: 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: cli

    This is a starting example; in production, pin third-party actions to verified commit SHAs and use controlled tool versions.

    The pipeline should:

    1. Trigger whenever an IaC pull request is created or updated.
    2. Validate the IaC syntax.
    3. Execute security and compliance scans.
    4. Publish findings as pipeline artifacts or pull-request annotations.
    5. Fail the pipeline when blocking policy violations are detected.
    6. 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.

    SeverityExampleRecommended action
    CriticalPublic database containing sensitive dataBlock deployment
    HighUnrestricted administrative accessBlock deployment
    MediumMissing encryption or loggingRequire remediation or approval
    LowMissing optional metadataTrack and remediate

    I would also map individual rules to recognized compliance frameworks.

    FrameworkRelevant areas
    CIS BenchmarksCloud security configurations
    NIST 800-53Access control, auditing, encryption
    SOC 2Security, availability, confidentiality
    PCI DSSPayment infrastructure security
    ISO 27001Information 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:

    1. Start in reporting mode to establish a baseline.
    2. Identify recurring issues and tune policies.
    3. Enforce blocking on newly introduced critical and high findings.
    4. 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:

    RequirementRecommended technology
    IaC static scanningCheckov
    Additional configuration scanningTrivy
    Terraform validationTerraform CLI
    Kubernetes validationkubeconform
    Custom compliance policiesOPA / Conftest
    Secret scanningTrivy or Gitleaks
    CI/CD enforcementGitHub Actions / GitLab CI
    Runtime complianceCSPM platform
    Compliance reportingSARIF and centralized dashboards

    Official documentation:

    7. Suggested implementation roadmap

    1. Phase 1 – Establish scanning

      Integrate Checkov into CI/CD and scan all existing Terraform, Kubernetes, and CloudFormation repositories.

    2. Phase 2 – Establish security standards

      Map built-in checks to CIS/NIST requirements and implement organization-specific policies.

    3. Phase 3 – Enforce compliance

      Introduce pull-request gates, severity-based blocking, and controlled exception management.

    4. Phase 4 – Extend coverage

      Add Terraform plan scanning, secret scanning, module vulnerability checks, and Kubernetes admission policies.

    5. 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.

  • Google AI ModeOct 4, 2026

    1. 1Open Policy Agent
    2. 2Checkov
    3. 3Tfsec

    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

    1. 1Checkov
    2. 2Trivy
    3. 3Terraform
    4. 4HashiCorp
    5. 5AWS
    6. 6Kubernetes
    7. 7Helm
    8. 8Pulumi
    9. 9Dockerfiles
    10. 10Open Policy Agent
    11. 11Azure Resource Manager
    12. 12Azure Bicep
    13. 13Center for Internet Security (CIS)
    14. 14National Institute of Standards and Technology (NIST)
    15. 15Microsoft Azure
    16. 16Google Cloud

    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 detection

    OWASP 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/0 ingress 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:

    rego
    package 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 / deny

    This catches problems that aren't always obvious from individual .tf files 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.

    LayerPurposeExamples
    IaC scannerKnown security misconfigurationsCheckov, Trivy
    Policy engineYour organization's rulesOPA, Sentinel
    Compliance baselineRegulatory/security frameworkCIS, NIST, PCI, etc.
    Secrets scannerCredentials accidentally committedsecret scanning tools
    Dependency checksProvider/module/image riskdependency/SBOM tooling
    Runtime scannerWhat actually existscloud 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:

    SeverityExampleAction
    CriticalPublic database, exposed credentialsHard fail
    HighPublic SSH/RDP, excessive IAMHard fail
    MediumMissing encryption/tagUsually fail
    LowNaming/documentation issueWarning
    AdvisoryRecommended optimizationReport only

    You can also introduce an exception mechanism, but exceptions should themselves be controlled artifacts:

    yaml
    exception:
      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@example

    Never allow developers to simply add something like:

    yaml
    skip: true

    without 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
                        │
                        ▼
                     APPLY

    This 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:

    hcl
    resource "aws_s3_bucket" "app" {
      bucket = var.name
    }

    provide something like:

    hcl
    module "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: Block

    This 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 tests

    For example:

    test_public_s3_bucket_denied
    test_private_s3_bucket_allowed
    test_bucket_with_exception_allowed
    test_expired_exception_denied

    HashiCorp 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 monitoring

    This 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 checks

    Gate 2 — Security

    IaC misconfiguration scanner
    secret scanner
    dependency/provider/module checks

    Gate 3 — Compliance

    terraform plan
            ↓
    OPA/Sentinel
            ↓
    organization policies
            ↓
    CIS/NIST/regulatory controls

    Gate 4 — Change risk

    Calculate risk from things such as:

    + production
    + IAM change
    + network perimeter change
    + encryption change
    + public exposure
    + data classification
    + destructive operation

    High-risk changes require additional approval.

    Gate 5 — Runtime

    continuous cloud posture scan
    +
    drift detection
    +
    alert/remediation

    My 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 state

    HashiCorp 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).

  • ChatGPTOct 11, 2026

    1. 1Trivy
    2. 2Checkov
    3. 3Open Policy Agent
    4. 4Conftest

    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.

    • Top 10 Open-Source Kubernetes Security Tools Every DevOps Engineer Needs in 2025 | by Baivab Mukhopadhyay | devdotcom | Medium

    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.

    Official documentation


    • Visualizing Checkov Output - checkov

    Checkov

    Best for teams that want broad IaC support, built-in checks, custom compliance policies, and CI/CD integration.

    Official documentation


    • OPA Ecosystem | Open Policy Agent

    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.

    OPA documentation ·

    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

    bash
    trivy config .

    B. Scan for exposed secrets and misconfigurations

    bash
    trivy fs --scanners secret,misconfig .

    C. Save findings as a JSON report

    bash
    trivy 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.

    CheckRecommended action
    Critical security issueBlock the merge or deployment
    High-severity issueBlock by default, with a documented exception process
    Medium/low findingsTrack, prioritize, and remediate according to policy
    Exposed credentialsBlock and rotate/revoke affected credentials
    Compliance violationBlock if it violates a mandatory control
    Accepted exceptionRecord 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]

    Google AI ModeOct 11, 2026

    1. 1Checkov
    2. 2Tfsec
    3. 3Trivy
    4. 4Aqua Security
    5. 5KICS
    6. 6cfn-lint
    7. 7Open Policy Agent
    8. 8HashiCorp Sentinel
    9. 9Bitbucket Cloud

    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, parse.gl/topics/iac-compliance-scanning.md.

This page

Reuse: Figures and tables on this page are free to republish with attribution: a link to https://parse.gl/topics/iac-compliance-scanning beside them. A standard followed link (dofollow) is preferred.

Read and search

Every brand's share on this topic, with 95% ranges: GET agent.parse.gl/v1/tools/query_metrics?args=%7B%22measures%22%3A%5B%22share_named%22%5D%2C%22by%22%3A%5B%22brand%22%5D%2C%22filter%22%3A%7B%22topic%22%3A%5B%22top_30ceac70-260e-4afa-b81d-8873cd9fa34a%22%5D%7D%7D
Search the index: GET parse.gl/api/public/search?q=<words>

Connect

Connect an assistant: agent.parse.gl/mcp

An agent can save work before signup: POST https://agent.parse.gl/v1/workspaces

What it costs

No account: Public figures and up to 5 examples per list, about 120 brands a day per address.
Free account: $5 in credit, your brand's first check (20 buyer questions) and a free weekly check.
After your first top-up: Exports and deeper search results. The first top-up starts at $5.
Live checks: $0.01 per question per engine.
Full public answers and pages: 25 free per day, then $0.005 each.