Add support for image_tag_mutability_exclusion_filter in ECR repositories @[copilot-swe-agent[bot]](https://github.com/apps/copilot-swe-agent) (#153)
This PR implements support for the `image_tag_mutability_exclusion_filter` feature in AWS ECR repositories, allowing fine-grained control over tag mutability settings.Problem
ECR repositories previously only supported global image_tag_mutability
settings (MUTABLE
or IMMUTABLE
), which applied to all tags uniformly. This created limitations in scenarios where users needed mixed mutability - for example, keeping production tags immutable while allowing development tags like latest
, dev-*
, or feature-*
to be mutable.
Solution
Added comprehensive support for image_tag_mutability_exclusion_filter
which allows users to define specific tag patterns that should be excluded from the repository's global mutability setting.
Key Changes
-
New Variable: Added
image_tag_mutability_exclusion_filter
variable with proper type definition:image_tag_mutability_exclusion_filter = [ { filter = "latest" filter_type = "WILDCARD" }, { filter = "dev-" filter_type = "WILDCARD" } ]
-
Dynamic Resource Block: Implemented dynamic block in
aws_ecr_repository
resource to conditionally apply exclusion filters. -
Comprehensive Validation: Added validation rules to ensure:
filter_type
must be a valid value (WILDCARD
)filter
values cannot be empty or whitespace-only
-
Provider Version Update: Updated minimum AWS provider version to
>= 6.8.0
to support this feature across all modules and examples.
Usage Example
module "ecr" {
source = "cloudposse/ecr/aws"
namespace = "company"
stage = "prod"
name = "api"
image_tag_mutability = "IMMUTABLE_WITH_EXCLUSIONS"
# Allow specific tag patterns to be mutable while keeping others immutable
image_tag_mutability_exclusion_filter = [
{
filter = "latest"
filter_type = "WILDCARD"
},
{
filter = "dev-"
filter_type = "WILDCARD"
}
]
}
This enables scenarios where production tags remain immutable for safety, while development and utility tags maintain flexibility for iterative workflows.
Documentation
Updated README.md with comprehensive documentation including:
- Advanced usage examples showing real-world scenarios
- Provider version requirements and migration notes
- Complete variable reference in the inputs table
Testing
- ✅ All Terraform validation passes
- ✅ Formatting checks pass across all modules
- ✅ Variable validation correctly catches invalid configurations
- ✅ Examples updated and validated
- ✅ Backward compatibility maintained
Breaking Changes
This is an additive feature that defaults to an empty list, preserving existing behavior.
HOWEVER the AWS Provider is updated two major versions.
Requirements
- AWS Provider >= 6.8.0 (updated across all modules and examples)
- Terraform >= 0.13.0 (unchanged)
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint-api.hashicorp.com
- Triggering command:
terraform version
(dns block)- Triggering command:
terraform init
(dns block)- Triggering command:
terraform fmt -check
(dns block)esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
This pull request was created as a result of the following prompt from Copilot chat.
Implement support for
image_tag_mutability_exclusion_filter
in the AWS ECR repository resource in main.tf. This entails:
- Adding a new variable to the module for configuring exclusion filters.
- Using a dynamic block for
image_tag_mutability_exclusion_filter
in the resource, referencing the new variable(s).- Documenting the new variable(s) in the README.md, with usage examples and a note about the minimum AWS provider version (>= 6.8.0).
- Updating versions.tf to bump the minimum AWS provider version to 6.8.0.
- Updating changelog and examples if needed.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.