8000 GitHub - asko123/terraform_integration_tests
[go: up one dir, main page]

Skip to content

asko123/terraform_integration_tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Integration Tests

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.

Project Structure

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

Prerequisites

  • Terraform (v1.0.0+)
  • AWS CLI
  • Go (v1.16+) for certain test helpers
  • Python (v3.9+) for test utilities

Setup

  1. Clone this repository:

    git clone https://github.com/yourusername/terraform_integration_tests.git
    cd terraform_integration_tests
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. 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
    

Running Tests

All Tests

./scripts/run_tests.sh

Specific Test Categories

./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

Test Types

Configuration Validation Tests

These tests verify that resources are configured according to best practices and security standards.

IAM Policy Tests

These tests validate IAM policies for proper permissions and least privilege principles.

Integration Tests

These tests verify that different AWS services interact correctly when deployed together.

Misconfiguration Tests

These tests deliberately introduce misconfigurations to ensure they are properly detected.

Mocking Strategy

This project uses several approaches for mocking AWS services:

  1. LocalStack: For local emulation of AWS services
  2. Custom mock implementations: For specific service behaviors
  3. Terraform's built-in testing framework: For plan validation

Contributing

  1. Create a new branch for your test implementation
  2. Implement the test cases following the existing patterns
  3. Run the tests locally to ensure they pass
  4. Submit a pull request with a description of your changes

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0