Terraform module to create a Public AWS ECR to share images in the ECR Public Gallery.
You can use this module to create a public ECR registry using objects definition, or using the variables approach:
Check the examples for the using objects and the *using variables snippets.
This example creates an public ECR registry:
module "public-ecr" {
source = "lgallard/ecrpublic/aws"
repository_name = "lgallard-public-repo"
catalog_data = {
about_text = "# Public repo\nPut your description here using Markdown format"
architectures = ["Linux"]
description = "Description"
logo_image_blob = filebase64("image.png")
operating_systems = ["ARM"]
usage_text = "# Usage\n How to use you image goes here. Use Markdown format"
}
}
This example creates an public ECR registry using variables
module "public-ecr" {
source = "lgallard/ecrpublic/aws"
repository_name = "lgallard-public-repo"
catalog_data_about_text = "# Public repo\nPut your description here using Markdown format"
catalog_data_architectures = ["Linux"]
catalog_data_description = "Description"
catalog_data_logo_image_blob = filebase64("image.png")
catalog_data_operating_systems = ["ARM"]
catalog_data_usage_text = "# Usage\n How to use you image goes here. Use Markdown format"
}
This module includes comprehensive automated testing using Terratest and GitHub Actions CI/CD.
Prerequisites:
Available commands:
# Check terraform formatting
make fmt-check
# Validate terraform configuration
make validate
# Run static tests (format check, validation, syntax tests)
make test
# Run integration tests (creates real AWS resources - requires AWS credentials)
make test-integration
# Run all static checks (recommended for development)
make check
# Run all checks including integration tests
make check-all
# Format terraform files
make fmt
# Clean up test artifacts
make clean
The test suite includes:
Static Tests (No AWS resources created):
- Terraform Format Check: Ensures all Terraform files are properly formatted
- Terraform Validation: Validates the main module configuration
- Examples Validation: Tests both
using_objects
andusing_variables
examples - Examples Format Check: Ensures example code is properly formatted
Integration Tests (Creates real AWS resources):
- ECR Public Repository Creation: Tests actual repository creation and configuration
- Catalog Data Integration: Verifies repository metadata and catalog information
- Example Deployment: Tests real-world usage scenarios
- Resource Cleanup: Ensures proper cleanup after testing
- Valid AWS credentials configured
- Appropriate permissions for ECR Public operations
- Access to the
us-east-1
region (required for ECR Public)
This repository includes a GitHub Actions workflow that automatically:
- Static Tests: Run on all pull requests and pushes
- Checks Terraform formatting with
terraform fmt -check
- Validates all Terraform configurations
- Executes static Terratest validation
- Checks Terraform formatting with
- Integration Tests: Run on main branch pushes or manual dispatch
- Creates and tests real ECR Public repositories
- Requires AWS credentials to be configured as GitHub secrets
- Automatically cleans up resources after testing
All static tests must pass before code can be merged. Integration tests provide additional confidence for production deployments.
No requirements.
Name | Version |
---|---|
aws | n/a |
No Modules.
Name |
---|
aws_ecrpublic_repository |
Name | Description | Type | Default | Required |
---|---|---|---|---|
catalog_data | Catalog data configuration for the repository. | any |
{} |
no |
catalog_data_about_text | A detailed description of the contents of the repository. It is publicly visible in the Amazon ECR Public Gallery. The text must be in markdown format. | string |
null |
no |
catalog_data_architectures | The system architecture that the images in the repository are compatible with. On the Amazon ECR Public Gallery, the following supported architectures will appear as badges on the repository and are used as search filters: Linux , Windows . |
list(string) |
[] |
no |
catalog_data_description | A short description of the contents of the repository. This text appears in both the image details and also when searching for repositories on the Amazon ECR Public Gallery. | string |
null |
no |
catalog_data_logo_image_blob | The base64-encoded repository logo payload. (Only visible for verified accounts) Note that drift detection is disabled for this attribute. | string |
null |
no |
catalog_data_operating_systems | The operating systems that the images in the repository are compatible with. On the Amazon ECR Public Gallery, the following supported operating systems will appear as badges on the repository and are used as search filters. 'ARM', 'ARM 64', 'x86', 'x86-64'. | list(string) |
null |
no |
catalog_data_usage_text | Detailed information on how to use the contents of the repository. It is publicly visible in the Amazon ECR Public Gallery. The usage text provides context, support information, and additional usage details for users of the repository. The text must be in markdown format. | string |
null |
no |
repository_name | Name of the repository. | string |
n/a | yes |
timeouts | Timeouts map. | map |
{} |
no |
timeouts_delete | How long to wait for a repository to be deleted. | string |
null |
no |
Name | Description |
---|---|
arn | Full ARN of the repository |
id | The repository name. |
registry_id | The registry ID where the repository was created. |
repository_uri | The URI of the repository. |