Join our Newsletter — 33% off our NHI Course

Why should organisations enforce cloud security baselines at the Infrastructure as Code layer?

Enforcing baselines at the IaC layer reduces the gap between intent and deployment. It helps teams stop insecure configurations before they reach production, keeps policy consistent across environments, and makes governance repeatable. For cloud programmes, that matters because manual checks are slow, inconsistent, and easy to bypass as infrastructure changes accelerate.

Why This Matters for Security Teams

Cloud security baselines are only useful when they are enforced before anything reaches a live account. That is why the Infrastructure as Code layer matters: it is the earliest reliable point where teams can block insecure storage, overly broad IAM, exposed services, and drift from approved standards. Guidance from ISO/IEC 27002:2022 Information Security Controls and the CSA Cloud Controls Matrix both point toward preventive control design, but IaC turns that principle into an enforceable delivery gate.

The practical risk is speed. Cloud teams ship changes continuously, and manual review cannot keep up without becoming inconsistent. The same weakness shows up in identity-heavy cloud incidents, including the Azure Key Vault privilege escalation exposure and the ASP.NET machine keys RCE attack, where exposed secrets and weak configuration handling became operational problems rather than theoretical ones.

NHIMG’s The 2026 Infrastructure Identity Survey found that 67% of organisations still rely heavily on static credentials despite the risks they pose to agentic AI deployments, which is a warning sign for cloud governance more broadly. In practice, many security teams discover baseline failures only after a misconfigured deployment has already reached production and started interacting with real data.

How It Works in Practice

Enforcing baselines at the IaC layer means policy checks happen where infrastructure intent is expressed, not after deployment. That can include Terraform, CloudFormation, Bicep, Pulumi, or platform modules, with controls applied through policy-as-code, CI checks, code review, and pipeline gates. The goal is not just to detect bad configuration, but to make non-compliant states impossible to merge or deploy.

A mature implementation usually combines several layers:

  • pre-commit or pull request checks for obvious misconfigurations
  • policy-as-code evaluation against defined baselines, such as encryption, logging, public exposure, and IAM scope
  • module and template standards that remove unsafe defaults
  • exception handling with expiry dates and approval trails
  • post-deploy drift detection to catch manual changes outside code

This approach works best when baseline rules are written in a way engineers can actually use. A policy that is too vague becomes bypassed, while one that is too rigid creates shadow infrastructure. For cloud identity and secrets handling, that is especially important because the attack path often starts with an over-permissioned role or long-lived credential. The operational lesson from the State of Non-Human Identity Security is simple: excessive privilege and poor rotation do not stay isolated to identity systems, they become deployment risk inside the infrastructure lifecycle itself.

Security teams should also align IaC baselines with platform guardrails and cloud-native controls so the same requirement is enforced in code, at runtime, and during change review. That reduces dependency on after-the-fact tickets and makes compliance repeatable across environments. These controls tend to break down when teams allow direct console changes in production because those changes bypass the code path where the baseline is actually enforced.

Common Variations and Edge Cases

Tighter IaC enforcement often increases delivery overhead, requiring organisations to balance deployment speed against consistency and risk reduction. That tradeoff is real, especially in teams that rely on rapid experimentation, multi-account sprawl, or inherited third-party templates. Current guidance suggests the answer is not to weaken baselines, but to make them modular, testable, and scoped to the environment.

One common edge case is shared infrastructure where a single module serves multiple business units. In that situation, baseline policy should distinguish between approved exceptions and accidental drift. Another is legacy infrastructure that cannot be fully expressed as code. Best practice is evolving here, but the usual pattern is to wrap legacy assets with compensating controls, then move them into managed templates over time rather than exempting them indefinitely.

There is also a difference between prevention and assurance. IaC baselines can stop unsafe resources from being created, but they do not replace runtime monitoring, configuration inventory, or incident response. They are strongest when paired with drift detection and access governance. The broader cloud security lesson is reinforced by incidents such as the Snowflake breach and the 230M AWS environment compromise, where identity, exposure, and control gaps became operational failures. The hard cases are organisations that treat IaC as documentation rather than enforcement, because policy only helps when it blocks the build.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 IaC baselines should prevent insecure NHI credential patterns at build time.
OWASP Agentic AI Top 10 A2 Autonomous tools and agents need runtime-safe policy guardrails in deployment pipelines.
CSA MAESTRO GOV-01 Cloud governance for automated delivery depends on preventive controls in the pipeline.
NIST AI RMF AI-assisted infrastructure changes require governance, measurement, and accountability.
NIST CSF 2.0 PR.IP-1 Security should be integrated into development and change processes, not added later.

Block long-lived or over-scoped NHI secrets in code and require short-lived, least-privilege alternatives.