TLDR overview
- Infrastructure as code scanning reviews source templates like Terraform and Kubernetes manifests for security misconfigurations before the infrastructure is deployed.
- It checks source files before deployment, so it does not assess the posture of deployed cloud resources or detect runtime behavior, and it does not replace those controls.
- Placing checks across the delivery workflow, from local feedback to pull-request checks to CI policy, catches misconfigurations when they are cheapest to fix.
- SonarQube reviews infrastructure as code files for misconfigurations as part of the same platform that reviews application code.
Your infrastructure now lives in source files. Networks, storage, access policies, and clusters are defined in templates that platform and DevOps teams write, review, and merge like any other code. That shift means there's now an early place in your deployment pipeline to catch security misconfigurations in your templates before you deploy the changes, but only if checks sit in the right stages of your delivery workflow.
This page explains what infrastructure as code (IaC) scanning is, how it differs from cloud-posture and runtime assessment, and where to place checks so findings arrive while the person who owns the scripts can still act on them. It is written for the teams who own the templates and the pipelines they move through: platform and DevOps engineers, cloud-security engineers, AppSec leads, and the engineers who maintain infrastructure.
What is infrastructure as code scanning?
Infrastructure as code scanning is the automated review of infrastructure as code source files, such as Terraform configurations, AWS CloudFormation, Azure Resource Manager or Kubernetes manifests, to detect security misconfigurations before the infrastructure is deployed. It reads the templates without provisioning the resources they describe, then flags settings that violate a defined policy.
In practice, these checks run against the files your team commits: a storage bucket set to public, a security group open to the internet, an unencrypted volume, or a secret written directly into a template. Because the review happens on source, it tells you what the template would create, not what a live cloud account currently looks like.
A plainer way to say it: infrastructure as code scanning reads your infrastructure definitions and tells you where they would create risk, so you can fix the code before anyone applies it.
Three types of assessment operate at different points, and conflating them creates blind spots:
- Source misconfiguration checks read templates before deployment. They catch issues the files declare, and they bound risk to what the source shows.
- Cloud security posture assessment reads deployed cloud resources. It detects drift, manual console changes, and the live state that source files never capture.
- Runtime assessment observes running workloads. It detects behavior, active threats, and conditions that only appear during execution.
Source scanning constrains risk early. It does not, however, verify the deployed configuration or observe workload behavior, so it complements rather than replaces posture and runtime controls.
Why does infrastructure as code scanning matter?
A misconfiguration in a template can carry over to production when the template is used to provision or update production resources. An overly permissive network rule, a public storage bucket, or a disabled encryption setting written into source will be provisioned exactly as declared, across every environment that consumes that template.
Checking IaC source early constrains the blast radius. Fixing a permissive rule in a pull request takes a developer a few minutes and leaves no exposure. Discovering the same rule after deployment means an open resource is already live, already reachable, and already part of your attack surface until someone notices and remediates it.
The stakes compound because of how infrastructure code moves. Shared modules propagate one misconfiguration to many environments. A single flawed template, reused across staging, production, and every team that imports it, turns one mistake into many. Source scanning detects the issue at the definition, before it fans out.
What should you inventory before choosing tooling?
Coverage is a decision you make before you adopt a scanner, not a number you accept from one. The right starting point is a map of what you actually need to check.
Which repositories hold infrastructure code
Infrastructure definitions can live in several places. They sit in dedicated platform repositories, inside application repositories alongside service code, and in shared module repositories that many teams import. Inventory all three. A scanner pointed only at your platform repository misses the Terraform a product team keeps next to its application.
Which file types and formats are in use
Terraform configurations and Kubernetes manifests are common, but repositories may also contain Helm charts, CloudFormation templates, Azure Resource Manager templates, Dockerfiles, and CI configuration files that provision infrastructure. List the formats your repositories contain, then confirm which ones a given scanner reviews. Format coverage varies by tool, and an unscanned format is an unscanned surface.
What the scope of checks actually is
Source scanning bounds its findings to what the template declares. It does not resolve every runtime value, and it does not see the deployed account. Several things break specifically in infrastructure pipelines that a general code-scanning checklist will not name:
- Unresolved variables and modules. Source files reference values injected at plan or apply time. A scanner reading the raw template cannot always see the final resolved value, so some findings depend on context the source does not show.
- Environment-specific values. The same module produces different configurations per environment. A check that passes for staging inputs may not reflect what production receives.
- Plan-time versus apply-time differences. What a template declares and what the provider actually creates can differ. Source scanning reads the declaration, not the applied result.
- Secrets in templates. Credentials hardcoded into infrastructure files are a distinct failure mode from application secrets, and they ship wherever the module ships.
Naming these limits up front sets honest expectations. Source scanning constrains risk in the files; it does not confirm the state of the deployed cloud.
Where should infrastructure as code checks run in the delivery workflow?
Checks deliver value in proportion to how early they reach the person who can fix the finding. Placing them across the delivery workflow, rather than at a single gate, means issues surface while context is fresh and remediation is cheap.
Local feedback as code is written
The earliest signal reaches the developer in their editor, before a commit. Catching a misconfiguration here costs minutes and prevents the issue from ever entering a branch. Local feedback relies on the individual developer running it, so it informs but does not enforce. That is the job of later stages.
Pull-request checks before merge
The pull request is where a check becomes a shared, enforceable standard. A scan triggered on every pull request reviews the proposed change, posts findings on the affected lines, and gives reviewers an objective signal about whether the template meets policy. This stage protects the main branch without depending on any one developer's local setup. It reviews the diff, so a clean pull-request check confirms the change, not the entire pre-existing repository.
CI policy as the enforced gate
Continuous integration is where policy becomes a pass or fail decision. A gate configured on new infrastructure code can fail the build when a change introduces a critical misconfiguration, holding the merge until the file is fixed. Scoping the gate to new code keeps existing findings from blocking delivery while preventing new issues from landing. The gate enforces the standard consistently; it does not assess whatever already runs in your cloud account.
How does a finding move from detection to resolution?
A finding is only useful if it leads to a fix. The following illustrative, sanitized example shows how one moves through the workflow. It is hypothetical, not a specific product rule.
Consider a generic Terraform-style resource that defines a storage bucket with public read access. Here is how it travels from detection to closure:
- Detection. A pull-request check flags the resource, posting a comment on the affected lines: the bucket permits public access and omits encryption at rest.
- Remediation. The developer replaces the public grant with one limited to the application role, then pushes the change to the same pull request.
- Retest. The check reruns automatically on the new commit. Because rule-based review returns the same result for the same input, a correctly fixed template clears the check consistently.
- Exception. If the finding is a false positive or an accepted risk, the team records that decision explicitly, marking the issue with a status such as False Positive or Accept so it does not block future builds. Every exception carries an owner and a reason.
The workflow constrains what reaches production. It bounds risk to what the source declares, and it does not confirm the live state of the deployed resource, which posture tooling assesses separately.
How do you govern and measure infrastructure as code scanning over time?
A scanning program holds up when ownership, evidence, and coverage are tracked deliberately. Without that discipline, findings stall, exceptions accumulate, and gaps go unnoticed.
Four practices keep the program honest:
- Assign ownership. Infrastructure findings often fall between platform and application teams, and an unowned finding is an unfixed finding. Name who triages and who remediates for each repository, so no finding sits in the gap between teams.
- Capture evidence. Record what was checked, what was found, and what the gate decided, tied to the commit. Time-stamped, traceable records turn each check into an auditable trail rather than a transient console message.
- Handle false positives deliberately. Route every disputed finding through an explicit status such as False Positive, Fixed, or Accept. Unmanaged noise erodes trust, and a scanner developers stop reading protects nothing.
- Document unsupported surfaces. Record the formats, repositories, and runtime conditions your scanning does not cover. Source scanning does not see the deployed account, so pair it with posture and runtime controls and name that boundary explicitly.
Measure coverage over time, not once. Track the share of infrastructure repositories and formats under scanning, the trend in new misconfigurations introduced, and the age of open exceptions. Exceptions that never expire are their own failure mode: set review dates so an accepted risk gets revisited rather than forgotten.
How can SonarQube help you scan infrastructure as code?
SonarQube reviews infrastructure as code files for security misconfigurations as part of the same platform that reviews your application code. Its analysis covers infrastructure definitions alongside application languages, so one standard applies across the codebase rather than a separate tool bolted onto your pipeline [CONFIRM: edition availability of IaC scanning; supported IaC formats and rules].
For platform and DevOps teams, that unified review carries a practical benefit: the same quality gate that governs application code can govern infrastructure code. A quality gate acts as a pass or fail checkpoint on new code, and it can fail a CI build or block a pull request merge when a change introduces a misconfiguration. You set the standard once, apply it consistently to every contributor, and keep legacy findings from blocking delivery by scoping the gate to new code.
SonarQube connects to the delivery stages where infrastructure code moves. Pull request analysis decorates the pull request with findings on the affected lines, giving reviewers an objective signal before merge. Quality profiles, the set of rules a scan runs, can be managed centrally and synced to developer environments, so the same rules apply from the editor through CI. It integrates with GitHub, GitLab, Bitbucket, Azure DevOps, Jenkins, and other CI systems [CONFIRM: which integrations and stages support IaC file checks specifically].
SonarQube's rule-based review is deterministic: the same template produces the same result every run, which is what makes a gate decision repeatable and an exception auditable. It reviews source files before deployment. It does not assess the posture of deployed cloud resources or detect runtime behavior, and it does not replace those controls. To get started, connect SonarQube to your infrastructure repositories and configure a quality gate that new infrastructure code must pass before merge.
