Getting Started
InfraSpec automatically generates executable test code from your plain English specifications, eliminating the need to write traditional test code yourself. When you describe your infrastructure requirements using Gherkin syntax, InfraSpec’s intelligent step definitions translate your natural language into real infrastructure actions and validations.
For example, when you write a simple assertion like:
Then the S3 bucket "my-bucket" should have an encryption configurationInfraSpec automatically:
- Generates the underlying test code to connect to AWS
- Parses the S3 bucket configuration
- Validates encryption settings against AWS APIs
- Provides clear, actionable error messages if validation fails
This means you can focus on what to test rather than how to test it. The tool handles all the complexity of API calls, retries, error handling, and result formatting automatically. You write the specifications, and InfraSpec generates the executable tests that run against your infrastructure.
Getting started
Install InfraSpec
Choose how you want to install InfraSpec:
Prebuilt Binaries
brew tap robmorgan/infraspec
brew install infraspecInitialize a Repo
Initialize a Git repo containing your infrastructure code:
infraspec init # This will create a ./features directory if it doesn't already existCreate a Simple Terraform Example
Copy and paste the following into a Terraform configuration:
provider "aws" {
region = "us-east-1"
}Create Your First Test
Create your first infrastructure test:
infraspec new dynamodb.featureRun it!
infraspec features/dynamodb.featureYou should see some output.