Terraform Provider Overview
InfraSpec’s Terraform provider enables you to provision infrastructure using Terraform and test it with natural language
scenarios. You can run terraform apply, validate outputs, and combine Terraform with provider-specific assertions for
comprehensive infrastructure testing.
Capabilities
- Provision Infrastructure: Execute
terraform initandterraform applyautomatically - Variable Management: Set variables using multiple formats (strings, numbers, booleans, maps)
- Output Validation: Verify Terraform outputs with exact or partial matching
- Provider Agnostic: Works with any Terraform configuration regardless of cloud provider
- Automatic Cleanup: Resources are automatically destroyed after tests complete
- Integration: Seamlessly combines with AWS, HTTP, and other provider assertions
How It Works
InfraSpec integrates Terraform operations directly into your Gherkin scenarios. When you write a step like:
When I run Terraform applyInfraSpec automatically:
- Runs
terraform initto initialize the configuration - Executes
terraform applywith your provided variables - Parses Terraform outputs for validation
- Tracks applied resources for cleanup
- Destroys resources after the scenario completes
All Terraform commands are executed in isolated working directories, ensuring test isolation.
Configuration
No special configuration is required for Terraform support. Simply ensure:
- Terraform is installed and available in your
PATH - Your Terraform configurations are valid
- Required provider credentials are configured (e.g., AWS credentials for AWS resources)
Next Steps
- Terraform Testing Guide - Comprehensive examples and grammar reference
- AWS Provider Overview - Combine Terraform with AWS-specific assertions
- Getting Started - Learn the basics of InfraSpec testing
Last updated on