Skip to content

Conversation

psantus
Copy link
Contributor

@psantus psantus commented Oct 10, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

N/A

Description

Improves data aws_ecr_images:

  • Filter image by tag status
  • MaxResults
  • Describe images

Relations

Fixes #40025

References

Output from Acceptance Testing

2025/10/10 23:57:57 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/10 23:57:57 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccECRImagesDataSource_basic
=== PAUSE TestAccECRImagesDataSource_basic
=== RUN   TestAccECRImagesDataSource_registryID
=== PAUSE TestAccECRImagesDataSource_registryID
=== RUN   TestAccECRImagesDataSource_describeImages
=== PAUSE TestAccECRImagesDataSource_describeImages
=== RUN   TestAccECRImagesDataSource_maxResults
=== PAUSE TestAccECRImagesDataSource_maxResults
=== RUN   TestAccECRImagesDataSource_tagStatus
=== PAUSE TestAccECRImagesDataSource_tagStatus
=== CONT  TestAccECRImagesDataSource_basic
=== CONT  TestAccECRImagesDataSource_maxResults
=== CONT  TestAccECRImagesDataSource_tagStatus
=== CONT  TestAccECRImagesDataSource_registryID
=== CONT  TestAccECRImagesDataSource_describeImages
--- PASS: TestAccECRImagesDataSource_describeImages (23.40s)
--- PASS: TestAccECRImagesDataSource_maxResults (23.45s)
--- PASS: TestAccECRImagesDataSource_basic (23.93s)
--- PASS: TestAccECRImagesDataSource_registryID (28.57s)
--- PASS: TestAccECRImagesDataSource_tagStatus (48.69s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        53.520s

...

- Add tag_status attribute to schema (TAGGED/UNTAGGED/ANY)
- Update data model and Read method to support ListImagesFilter
- Add comprehensive tests for all tag_status values
- Update documentation with examples
- Add max_results attribute to schema with int64 type
- Update data model and Read method to set MaxResults on ListImagesInput
- Add test for max_results functionality
- Update documentation with example usage
- Add describe_images boolean attribute to schema (defaults to false)
- Add image_details output attribute with detailed image information
- Create imageDetailsModel struct for DescribeImages API response
- Add findImagesDetails function with batching (max 100 images per request)
- Update Read method to conditionally call DescribeImages when describe_images=true
- Add comprehensive test for describe_images functionality
- Update documentation with examples and detailed attribute descriptions
- Align struct field tags for consistency
Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/ecr Issues and PRs that pertain to the ecr service. size/L Managed by automation to categorize the size of a PR. labels Oct 10, 2025
@psantus psantus changed the title Feat/aws ecr images add properties data.aws_ecr_images add tag status filter, max results and describe image Oct 10, 2025
Add changelog entry for ECR images data source enhancements:
- tag_status filter (TAGGED/UNTAGGED/ANY)
- max_results parameter
- describe_images functionality with image_details output
Remove 'Defaults to ANY' from tag_status documentation as there is no
default value set in the implementation. The parameter is optional and
when not specified, the AWS API returns all images regardless of tag status.
- Use public ECR registry (amazonlinux) with real images for testing
- Add testAccCheckECRImagesAllHaveTags validation function
- Verify TAGGED filter returns only images with tags
- Test now validates actual filtering behavior, not just parameter acceptance

Addresses review feedback about test coverage for tag_status filtering.
Replace 'true' string literal with acctest.CtTrue constant in test
to comply with semgrep rule ci.literal-True-string-test-constant
Remove extra spaces in attribute alignment to match terrafmt standards
Replace if statement with modern min() function for calculating
batch end index in findImagesDetails function
Rename testAccCheckECRImagesAllHaveTags to testAccCheckImagesAllHaveTags
to comply with semgrep rule ci.ecr-in-func-name
Function is no longer used after updating test to use public ECR registry
Replace traditional for loop with modern range over int syntax
@psantus psantus marked this pull request as ready for review October 11, 2025 12:30
@psantus psantus requested a review from a team as a code owner October 11, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. needs-triage Waiting for first response or review from a maintainer. service/ecr Issues and PRs that pertain to the ecr service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: aws_ecr_images with filter

1 participant