This repository contains integration tests for Terraform AWS service configurations using mocks and fakes. The tests ensure proper configuration and validation of AWS services, with a focus on detecting misconfigurations and IAM policy violations.
terraform_integration_tests/
├── README.md # This file
├── tests/ # Contains all test files
│ ├── s3_tests/ # S3 bucket tests
│ ├── iam_tests/ # IAM policy tests
│ ├── rds_tests/ # RDS configuration tests
│ └── lambda_tests/ # Lambda configuration tests
├── fixtures/ # Test fixtures and mocks
│ ├── s3/ # S3 mocks and fixture data
│ ├── iam/ # IAM policy fixtures
│ ├── rds/ # RDS configuration fixtures
│ └── lambda/ # Lambda configuration fixtures
├── modules/ # Reusable Terraform modules
└── scripts/ # Helper scripts for test execution
- Terraform (v1.0.0+)
- AWS CLI
- Go (v1.16+) for certain test helpers
- Python (v3.9+) for test utilities
-
Clone this repository:
git clone https://github.com/yourusername/terraform_integration_tests.git cd terraform_integration_tests
-
Install dependencies:
pip install -r requirements.txt
-
Configure AWS credentials for testing (mock mode):
export AWS_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test
./scripts/run_tests.sh
./scripts/run_tests.sh s3 # Run only S3 tests
./scripts/run_tests.sh iam # Run only IAM tests
./scripts/run_tests.sh rds # Run only RDS tests
./scripts/run_tests.sh lambda # Run only Lambda tests
These tests verify that resources are configured according to best practices and security standards.
These tests validate IAM policies for proper permissions and least privilege principles.
These tests verify that different AWS services interact correctly when deployed together.
These tests deliberately introduce misconfigurations to ensure they are properly detected.
This project uses several approaches for mocking AWS services:
- LocalStack: For local emulation of AWS services
- Custom mock implementations: For specific service behaviors
- Terraform's built-in testing framework: For plan validation
- Create a new branch for your test implementation
- Implement the test cases following the existing patterns
- Run the tests locally to ensure they pass
- Submit a pull request with a description of your changes
MIT