Home/Glossary/Infrastructure as Code (IaC)

Infrastructure as Code (IaC)

Managing and provisioning infrastructure through machine-readable configuration files rather than manual processes.

DevSecOpsAlso called: "iac", "infrastructure automation", "declarative infrastructure"

Infrastructure as Code treats infrastructure configuration like software code—versioned, tested, and deployed through automated pipelines.

Popular IaC tools

  • Terraform: Cloud-agnostic, declarative, state-based.
  • AWS CloudFormation: AWS-native, JSON/YAML templates.
  • Azure Bicep/ARM: Azure-native infrastructure templates.
  • Pulumi: General-purpose languages (Python, TypeScript, Go).
  • Ansible: Procedural, agentless configuration management.

Security benefits

  • Version control: Track all infrastructure changes in Git.
  • Peer review: Pull requests catch misconfigurations before deployment.
  • Consistency: Eliminate configuration drift between environments.
  • Auditability: Complete history of who changed what and when.
  • Rapid recovery: Recreate infrastructure from code after incidents.

Security risks to manage

  • Secrets in code: Never commit credentials; use secret managers.
  • State file exposure: Terraform state contains sensitive data.
  • Overly permissive defaults: Review resource configurations carefully.
  • Drift detection: Monitor for out-of-band changes.

Best practices

  1. Store state remotely with encryption (S3, Azure Blob, GCS).
  2. Use policy-as-code tools (OPA, Sentinel) for guardrails.
  3. Scan IaC files with tools like Checkov, tfsec, or Terrascan.
  4. Implement least-privilege for IaC pipeline service accounts.
  5. Use modules for consistent, reusable configurations.