Testaws
Python library for testing AWS infrastructure with pytest and Terraform helpers.

What it is
test-aws is a Python package that provides helper functions for writing pytest tests against AWS infrastructure. It includes Terraform helpers to look up variables, data sources, and other Terraform objects. The library enables testing deployed resources rather than deployment code, making broad assertions about infrastructure state. It integrates with pytest fixtures to retrieve instances, check security group rules, verify public and elastic IPs, and validate instance types and termination protection. It also supports Terraform variable lookup for dynamic test configuration.
DevOps engineers, cloud engineers, and developers who manage AWS infrastructure with Terraform and want to implement continuous testing in production will find this tool useful. It helps teams ensure security compliance, such as ensuring no SSH access from the world, and that web instances only accept traffic from approved offices.
To get started, install via pip, create a test directory, define pytest fixtures in conftest.py to fetch AWS resources and Terraform variables, then write test modules that assert infrastructure properties. The documentation provides complete examples for common scenarios like testing web instance accessibility and network rules.
test-aws follows a philosophy of testing deployed resources in production using existing tools (pytest, Python) rather than introducing new IaC-specific testing frameworks. It is open source, though not yet considered stable, so version pinning is recommended. Alternatives include Terratest, kitchen-terraform, Chef InSpec, and Serverspec.
This description was generated by AI from the site's public content and may contain errors.
What you can do there
- Read documentation and usage examples for test-aws
- Learn how to write pytest tests for AWS infrastructure
- See examples of Terraform variable integration
- Compare test-aws with other infrastructure testing tools
- Access the project's development guidelines and contribution notes
Who it's for
DevOps engineers, cloud engineers, and developers testing AWS infrastructure with pytest and Terraform.
Frequently asked questions about testaws.readthedocs.io
›What is test-aws used for?
test-aws is used to write pytest tests that verify the state of deployed AWS infrastructure, such as security group rules, instance types, and network configuration.
›How do I install test-aws?
Install test-aws with pip by running pip install test-aws in your environment.
›Can test-aws work with Terraform variables?
Yes, test-aws includes helpers to look up Terraform variables and data sources for use in test fixtures.
›Does test-aws support testing in production environments?
The library encourages testing in production as part of its philosophy, allowing continuous validation of live infrastructure.
›What are some alternatives to test-aws?
Alternatives include Terratest, kitchen-terraform, Chef InSpec, and Serverspec for infrastructure testing.
›Is test-aws stable for production use?
The project states it should not be considered stable yet and recommends pinning versions in requirements.
›How do I write a test for AWS security group rules?
Use the provided helpers like instances_ingress_rules_for_port and instances_port_ingress_sources to assert allowed CIDRs and security groups.
