liveBook · Manning

Static analysis

As explained in Effective Platform Engineering

Static analysis is the automated examination of source code or related artifacts without executing the analyzed software.

Static analysis checks source code without deploying or running the software it defines. For infrastructure as code (IaC), it provides early feedback on syntax, formatting, conventions, and security problems—locally and in CI. Because IaC is highly declarative, checks such as cyclomatic complexity and test coverage are less useful than they are for imperative code. section 6.3.6

A practical Terraform feedback loop separates three kinds of checks:

  • Run Terraform CLI validation and formatting checks; correct syntax errors and apply canonical formatting. section 6.3.6
  • Run Tflint for deprecations, cloud-provider parameters, best practices, and naming conventions. Configure its AWS plugin when checking AWS resources. section 6.3.6
  • Run Trivy’s config scan against Terraform files, then correct reported security problems. section 6.3.6
plugin "terraform" {
  enabled = true
  preset  = "all"
}
plugin "aws" {
  enabled = true
  version = "0.30.0"
  source  = "github.com/terraform-linters/tflint-ruleset-aws"
}

This Tflint configuration enables Terraform checks and an AWS ruleset, making the linting step specific to the cloud provider in use. section 6.3.6

Check a Terraform change before deployment

For a main.tf containing a VPC and an ingress rule open to 0.0.0.0/0 across ports 0–65535, validate and format the file, clear Tflint warnings, and scan it with Trivy. Treat the findings as changes to make and recheck, not as a substitute for testing the deployed configuration. section 6.3.6 section 6.3.3

In an infrastructure pipeline, static analysis belongs in CI before deployment to the first test environment. A Terraform plan then shows expected changes; after apply, tests can compare actual configuration with the desired state. Recurring tests serve a different purpose: detecting drift from manual changes. section 6.3.3 section 6.4.4

How Effective Platform Engineering covers it

How deep it goes
Details Terraform validation, formatting, linting, and security scans, but leaves deployed-state verification to later pipeline tests.
Examples
Uses a Terraform VPC and ingress rule, Tflint AWS plugin configuration, and a Trivy scan.
What it assumes
Assumes familiarity with infrastructure-as-code and CI while supplying concrete Terraform commands and a Tflint configuration.
What you can do after
Apply it via Terraform CLI, Tflint, and Trivy to correct validation errors, lint warnings, and security findings before deployment.
How it connects
Connects infrastructure as code with CI, Terraform plans, security scanning, configuration drift, and post-deployment testing.

Also explained in

Compare how 6 books explain static analysis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Platform Engineering. The section links point to the parts of the book it draws on.