Skip to Content
DocsGetting Started

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 configuration

InfraSpec 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:

brew tap robmorgan/infraspec brew install infraspec

Initialize a Repo

Initialize a Git repo containing your infrastructure code:

infraspec init # This will create a ./features directory if it doesn't already exist

Create a Simple Terraform Example

Copy and paste the following into a Terraform configuration:

main.tf
provider "aws" { region = "us-east-1" }

Create Your First Test

Create your first infrastructure test:

infraspec new dynamodb.feature

Run it!

infraspec features/dynamodb.feature

You should see some output.

Last updated on