Infrastructure as Code Security
Analyse Terraform, Kubernetes manifests, Helm charts and CloudFormation for insecure configuration before apply.
IntermediateInfrastructure as Code SecurityInfrastructureCloud
Where it fits in the lifecycle
- Plan
- Code
- Build
- Test
- Release
- Deploy
- Operate
- Monitor
- Code Static analysis, secret detection and secure coding practices.
- Build Dependency scanning, image scanning, SBOM generation and signing.
Overview
Infrastructure defined as code can be reviewed like code. IaC scanners evaluate resource definitions against policy — public storage, unencrypted volumes, permissive security groups, missing logging — before anything is provisioned.
Why it matters
Cloud misconfiguration is a leading cause of exposure. Catching it in the merge request avoids remediating live infrastructure under pressure.
How it works
- 01Templates or plan output are parsed into a resource graph.
- 02Built-in and custom policies evaluate each resource and its relationships.
- 03Results are reported with the file, resource address and remediation guidance.
- 04Scanning the plan file catches values resolved only at apply time.
Common tools
CheckovtfsecKICSTerrascanTerraformKubernetesAWSAzure
Implementation examples
bashScan a Terraform directory
checkov -d . --framework terraform --compactbashScan the plan for resolved values
terraform plan -out tfplan.binaryterraform show -json tfplan.binary > tfplan.jsoncheckov -f tfplan.jsonSecurity considerations
- Plan JSON can contain sensitive values; do not publish it as a public artefact.
Best practices
- Scan both templates and plan output.
- Write custom policies for organisation-specific rules such as required tags.
- Keep suppressions inline with a justification comment and an owner.
Common mistakes
- Only scanning templates and missing runtime-resolved configuration.
- Allowing broad blanket skips at the repository level.
Hands-on labs
- Lab 03 — Secure Terraform with Checkov
Find and fix insecure Terraform configuration before applying it.