AWS Builder Center

Introducing Preflight: Catch Infrastructure Risks Before

Preflight, a lightweight CLI that analyzes Terraform execution plans against predefined cloud-provider policies and infrastructure safety rules.

SBGL - DY Patil International University
One thing I've noticed while working with Terraform is that writing valid infrastructure code and understanding the actual infrastructure changes Terraform will make are two very different things.
Static analysis tools are useful for identifying configuration issues, enforcing best practices, and maintaining code quality. But they don't always tell you what will happen when Terraform reconciles your configuration with the existing infrastructure.
That's where the Terraform execution plan becomes important.
A seemingly small configuration change can sometimes result in a resource being replaced entirely rather than updated in place. Other changes might introduce security or compliance risks that aren't immediately obvious from reviewing the Terraform configuration.
I wanted to build something that could help identify these risks before infrastructure changes are applied.
That's how Preflight came about.
Preflight is a lightweight CLI tool that analyzes Terraform execution plan JSON before "terraform apply".
What does Preflight do?
Preflight evaluates planned infrastructure changes against a collection of predefined rules based on cloud-provider policies and infrastructure safety considerations.
For example, in an AWS environment, policy checks could identify changes such as:
- An S3 bucket being configured for public access. - Encryption being removed from an EBS volume. - A security group exposing SSH (port 22) to "0.0.0.0/0". - Critical infrastructure resources being scheduled for destruction or replacement.
The idea is to go beyond simply identifying whether a resource is changing and examine whether that change introduces a potential infrastructure risk.
The initial version includes 18 core analysis rules.
Why Terraform plan analysis?
Terraform configuration tells us what we want our infrastructure to look like. The execution plan tells us how Terraform intends to get there.
That distinction matters.
A configuration might look perfectly reasonable in isolation, but the resulting execution plan could reveal destructive replacements, unexpected deletions, or changes to security-sensitive attributes.
Preflight focuses on analyzing that planned outcome.
It doesn't aim to replace Terraform linters, security scanners, or cloud-provider policy engines. Instead, it explores an additional layer of infrastructure validation between generating a plan and applying it.
What's next?
Preflight is still evolving.
Some areas I want to explore further include:
- More comprehensive AWS and other cloud-provider policy coverage. - Infrastructure change risk scoring. - Dependency-aware analysis and blast-radius estimation. - More actionable explanations for detected risks.
The long-term goal is to make infrastructure changes more predictable and give engineers better visibility into what they're about to apply.
I'd love to hear how other engineers approach Terraform plan analysis, cloud policy enforcement, and infrastructure change risk assessment.
#AWS #Terraform #InfrastructureAsCode #DevOps #CloudSecurity #CloudEngineering #PlatformEngineering #OpenSource
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article