This directory contains automated tests for the terraform-aws-ecr module. The tests use Terratest, a Go library that provides utilities for testing Terraform code.
- Go (version 1.16 or later)
- Terraform (version 1.3.0 or later)
- AWS credentials configured (via environment variables, shared credentials file, or AWS IAM role)
To run all tests:
cd test
go test -vTo run a specific test:
cd test
go test -v -run TestEcrBasicCreationThe test suite includes the following tests:
-
Basic Repository Test: Tests the creation of a simple ECR repository with minimal configuration.
- Verifies repository creation
- Checks image tag mutability
- Validates repository URL and ARN
-
Complete Repository Test: Tests the creation of a fully configured ECR repository.
- Verifies repository creation with all features
- Validates repository policies
- Checks lifecycle policies
- Tests KMS encryption
The test fixtures are located in the fixtures directory:
fixtures/basic: A simple ECR repository configurationfixtures/complete: A full-featured ECR repository configuration with policies and KMS encryption
These tests create real AWS resources, which might incur costs. The tests use the force_delete = true option to ensure that repositories can be cleaned up even if they contain images.
All resources are tagged with Test = "true" for identification and are destroyed after the test completes. However, if a test fails, you may need to manually delete the resources.
These tests can be run in GitHub Actions using the workflow defined in .github/workflows/test.yml.