Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECR - Add ability to query by and return most recent image tag(s) #26857

Merged
merged 14 commits into from
Feb 22, 2023

Conversation

mtt88
Copy link
Contributor

@mtt88 mtt88 commented Sep 19, 2022

Add most_recent attribute to data source aws_ecr_image which will return the most recently pushed tag(s) for an ecr image.
Add most_recent_image_tags to data source aws_ecr_repository which will return the most recently pushed tag(s) for an ecr repository.

Questions:

How best to add tests for this new functionality? I've extended the existing tests in a limited way to check the existence of these new attributes but I am unsure how best to test that they are correct?
Do we want to add most_recent_image_tags to the aws_ecr_repository resource in addition to the data source?

Closes #12798.
Closes #26658.

Output from acceptance testing:

make testacc TESTS=TestAccECRRepositoryDataSource PKG=ecr
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRRepositoryDataSource'  -timeout 180m
=== RUN   TestAccECRRepositoryDataSource_basic
=== PAUSE TestAccECRRepositoryDataSource_basic
=== RUN   TestAccECRRepositoryDataSource_encryption
=== PAUSE TestAccECRRepositoryDataSource_encryption
=== RUN   TestAccECRRepositoryDataSource_nonExistent
=== PAUSE TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_basic
=== CONT  TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_encryption
--- PASS: TestAccECRRepositoryDataSource_nonExistent (5.34s)
--- PASS: TestAccECRRepositoryDataSource_basic (24.90s)
--- PASS: TestAccECRRepositoryDataSource_encryption (29.48s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        29.531s


 make testacc TESTS=TestAccECRImageDataSource PKG=ecr
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRImageDataSource'  -timeout 180m
=== RUN   TestAccECRImageDataSource_ecrImage
=== PAUSE TestAccECRImageDataSource_ecrImage
=== CONT  TestAccECRImageDataSource_ecrImage
--- PASS: TestAccECRImageDataSource_ecrImage (26.71s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        26.759s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Please 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 size/M Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. service/ecr Issues and PRs that pertain to the ecr service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 19, 2022
@breathingdust breathingdust added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 11, 2022
Acceptance test output:

% make testacc TESTARGS='-run=TestAccECRImageDataSource_basic' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRImageDataSource_basic -timeout 180m
=== RUN   TestAccECRImageDataSource_basic
=== PAUSE TestAccECRImageDataSource_basic
=== CONT  TestAccECRImageDataSource_basic
--- PASS: TestAccECRImageDataSource_basic (14.72s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	20.070s
Acceptance test output:

% make testacc TESTARGS='-run=TestAccECRImageDataSource_basic' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRImageDataSource_basic -timeout 180m
=== RUN   TestAccECRImageDataSource_basic
=== PAUSE TestAccECRImageDataSource_basic
=== CONT  TestAccECRImageDataSource_basic
--- PASS: TestAccECRImageDataSource_basic (18.37s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	23.594s
Acceptance test output:

% make testacc TESTARGS='-run=TestAccECRRepositoryDataSource_' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRRepositoryDataSource_ -timeout 180m
=== RUN   TestAccECRRepositoryDataSource_basic
=== PAUSE TestAccECRRepositoryDataSource_basic
=== RUN   TestAccECRRepositoryDataSource_encryption
=== PAUSE TestAccECRRepositoryDataSource_encryption
=== RUN   TestAccECRRepositoryDataSource_nonExistent
=== PAUSE TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_basic
=== CONT  TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_encryption
--- PASS: TestAccECRRepositoryDataSource_nonExistent (3.81s)
--- PASS: TestAccECRRepositoryDataSource_basic (16.31s)
--- PASS: TestAccECRRepositoryDataSource_encryption (18.35s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	23.452s
Acceptance test output:

% make testacc TESTARGS='-run=TestAccECRRepository_' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRRepository_ -timeout 180m
=== RUN   TestAccECRRepository_basic
=== PAUSE TestAccECRRepository_basic
=== RUN   TestAccECRRepository_disappears
=== PAUSE TestAccECRRepository_disappears
=== RUN   TestAccECRRepository_tags
=== PAUSE TestAccECRRepository_tags
=== RUN   TestAccECRRepository_immutability
=== PAUSE TestAccECRRepository_immutability
=== RUN   TestAccECRRepository_Image_scanning
=== PAUSE TestAccECRRepository_Image_scanning
=== RUN   TestAccECRRepository_Encryption_kms
=== PAUSE TestAccECRRepository_Encryption_kms
=== RUN   TestAccECRRepository_Encryption_aes256
=== PAUSE TestAccECRRepository_Encryption_aes256
=== CONT  TestAccECRRepository_basic
=== CONT  TestAccECRRepository_Encryption_aes256
=== CONT  TestAccECRRepository_immutability
--- PASS: TestAccECRRepository_immutability (20.48s)
=== CONT  TestAccECRRepository_Encryption_kms
--- PASS: TestAccECRRepository_basic (20.67s)
=== CONT  TestAccECRRepository_tags
--- PASS: TestAccECRRepository_Encryption_aes256 (38.39s)
=== CONT  TestAccECRRepository_Image_scanning
--- PASS: TestAccECRRepository_Encryption_kms (35.21s)
=== CONT  TestAccECRRepository_disappears
--- PASS: TestAccECRRepository_tags (41.06s)
--- PASS: TestAccECRRepository_disappears (12.06s)
--- PASS: TestAccECRRepository_Image_scanning (42.06s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	85.790s
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Feb 22, 2023
@ewbankkit ewbankkit marked this pull request as ready for review February 22, 2023 19:51
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccECRRepository_' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRRepository_ -timeout 180m
=== RUN   TestAccECRRepository_basic
=== PAUSE TestAccECRRepository_basic
=== RUN   TestAccECRRepository_disappears
=== PAUSE TestAccECRRepository_disappears
=== RUN   TestAccECRRepository_tags
=== PAUSE TestAccECRRepository_tags
=== RUN   TestAccECRRepository_immutability
=== PAUSE TestAccECRRepository_immutability
=== RUN   TestAccECRRepository_Image_scanning
=== PAUSE TestAccECRRepository_Image_scanning
=== RUN   TestAccECRRepository_Encryption_kms
=== PAUSE TestAccECRRepository_Encryption_kms
=== RUN   TestAccECRRepository_Encryption_aes256
=== PAUSE TestAccECRRepository_Encryption_aes256
=== CONT  TestAccECRRepository_basic
=== CONT  TestAccECRRepository_Encryption_aes256
=== CONT  TestAccECRRepository_immutability
--- PASS: TestAccECRRepository_immutability (20.48s)
=== CONT  TestAccECRRepository_Encryption_kms
--- PASS: TestAccECRRepository_basic (20.67s)
=== CONT  TestAccECRRepository_tags
--- PASS: TestAccECRRepository_Encryption_aes256 (38.39s)
=== CONT  TestAccECRRepository_Image_scanning
--- PASS: TestAccECRRepository_Encryption_kms (35.21s)
=== CONT  TestAccECRRepository_disappears
--- PASS: TestAccECRRepository_tags (41.06s)
--- PASS: TestAccECRRepository_disappears (12.06s)
--- PASS: TestAccECRRepository_Image_scanning (42.06s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	85.790s
% make testacc TESTARGS='-run=TestAccECRRepositoryDataSource_' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRRepositoryDataSource_ -timeout 180m
=== RUN   TestAccECRRepositoryDataSource_basic
=== PAUSE TestAccECRRepositoryDataSource_basic
=== RUN   TestAccECRRepositoryDataSource_encryption
=== PAUSE TestAccECRRepositoryDataSource_encryption
=== RUN   TestAccECRRepositoryDataSource_nonExistent
=== PAUSE TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_basic
=== CONT  TestAccECRRepositoryDataSource_nonExistent
=== CONT  TestAccECRRepositoryDataSource_encryption
--- PASS: TestAccECRRepositoryDataSource_nonExistent (3.81s)
--- PASS: TestAccECRRepositoryDataSource_basic (16.31s)
--- PASS: TestAccECRRepositoryDataSource_encryption (18.35s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	23.452s
% make testacc TESTARGS='-run=TestAccECRImageDataSource_basic' PKG=ecr ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRImageDataSource_basic -timeout 180m
=== RUN   TestAccECRImageDataSource_basic
=== PAUSE TestAccECRImageDataSource_basic
=== CONT  TestAccECRImageDataSource_basic
--- PASS: TestAccECRImageDataSource_basic (18.37s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	23.594s

@ewbankkit
Copy link
Contributor

@mtt88 Thanks for the contribution 🎉 👏.
I could test the most_recent functionality for the aws_ecr_image data source by ensuring that it has the "latest" tag.

@ewbankkit ewbankkit merged commit 29a61c1 into hashicorp:main Feb 22, 2023
@github-actions github-actions bot added this to the v4.56.0 milestone Feb 22, 2023
@github-actions
Copy link

This functionality has been released in v4.56.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/ecr Issues and PRs that pertain to the ecr service. size/XL 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
3 participants