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

r/aws_ecr_repository_creation_template: New resource. #38597

Merged
merged 5 commits into from
Jul 31, 2024

Conversation

bodgit
Copy link
Contributor

@bodgit bodgit commented Jul 30, 2024

Description

Adds support for ECR Repository Creation Templates.

Example:

resource "aws_ecr_repository_creation_template" "example" {
  prefix               = "example"
  description          = "A description"
  image_tag_mutability = "IMMUTABLE"
  custom_role_arn      = "arn:aws:iam::123456689012:role/somerole"

  applied_for = [
    "PULL_THROUGH_CACHE",
  ]

  encryption_configuration {
    encryption_type = "AES256"
  }

  lifecycle_policy = ""

  repository_policy = ""

  resource_tags = {
    One = "Two"
  }
}

Relations

Closes #34503

References

Output from Acceptance Testing

% make testacc TESTS=TestAccECRRepositoryCreationTemplate PKG=ecr
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRRepositoryCreationTemplate'  -timeout 360m
=== RUN   TestAccECRRepositoryCreationTemplate_basic
=== PAUSE TestAccECRRepositoryCreationTemplate_basic
=== RUN   TestAccECRRepositoryCreationTemplate_disappears
=== PAUSE TestAccECRRepositoryCreationTemplate_disappears
=== RUN   TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== PAUSE TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== RUN   TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
=== PAUSE TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
=== RUN   TestAccECRRepositoryCreationTemplate_repository
=== PAUSE TestAccECRRepositoryCreationTemplate_repository
=== CONT  TestAccECRRepositoryCreationTemplate_basic
=== CONT  TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
=== CONT  TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== CONT  TestAccECRRepositoryCreationTemplate_repository
=== CONT  TestAccECRRepositoryCreationTemplate_disappears
--- PASS: TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists (20.66s)
--- PASS: TestAccECRRepositoryCreationTemplate_disappears (35.03s)
--- PASS: TestAccECRRepositoryCreationTemplate_basic (40.05s)
--- PASS: TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle (43.23s)
--- PASS: TestAccECRRepositoryCreationTemplate_repository (51.35s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        51.500s

@bodgit bodgit requested a review from a team as a code owner July 30, 2024 15:46
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

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • 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 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. generators Relates to code generators. needs-triage Waiting for first response or review from a maintainer. labels Jul 30, 2024
@bodgit bodgit force-pushed the ecr-repository-creation-template branch from c3d1a54 to b1d3b0a Compare July 30, 2024 16:17
@bodgit bodgit force-pushed the ecr-repository-creation-template branch from b1d3b0a to 5232328 Compare July 30, 2024 23:36
@bodgit
Copy link
Contributor Author

bodgit commented Jul 30, 2024

I found I had to tweak the semgrep configuration as it was failing due to matching the resourceRepositoryCreationTemplateCreate function name against the /(?i)ECR/ pattern, (took me a moment to spot it).

Tests are all passing now, let me know if I've missed anything.

@bodgit
Copy link
Contributor Author

bodgit commented Jul 31, 2024

Have a data source as well:

data "aws_ecr_repository_creation_template" "example" {
  prefix = "example"
}
% make testacc TESTS=TestAccECRRepositoryCreationTemplateDataSource PKG=ecr
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRRepositoryCreationTemplateDataSource'  -timeout 360m
=== RUN   TestAccECRRepositoryCreationTemplateDataSource_basic
=== PAUSE TestAccECRRepositoryCreationTemplateDataSource_basic
=== CONT  TestAccECRRepositoryCreationTemplateDataSource_basic
--- PASS: TestAccECRRepositoryCreationTemplateDataSource_basic (14.27s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        14.378s

@bodgit bodgit force-pushed the ecr-repository-creation-template branch from 7d8ab06 to 8acc191 Compare July 31, 2024 10:07
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jul 31, 2024
@ewbankkit ewbankkit self-assigned this Jul 31, 2024
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jul 31, 2024
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=TestAccECRRepositoryCreationTemplate' PKG=ecr ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.5 test ./internal/service/ecr/... -v -count 1 -parallel 3  -run=TestAccECRRepositoryCreationTemplate -timeout 360m
=== RUN   TestAccECRRepositoryCreationTemplateDataSource_basic
=== PAUSE TestAccECRRepositoryCreationTemplateDataSource_basic
=== RUN   TestAccECRRepositoryCreationTemplate_basic
=== PAUSE TestAccECRRepositoryCreationTemplate_basic
=== RUN   TestAccECRRepositoryCreationTemplate_disappears
=== PAUSE TestAccECRRepositoryCreationTemplate_disappears
=== RUN   TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== PAUSE TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== RUN   TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
=== PAUSE TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
=== RUN   TestAccECRRepositoryCreationTemplate_repository
=== PAUSE TestAccECRRepositoryCreationTemplate_repository
=== CONT  TestAccECRRepositoryCreationTemplateDataSource_basic
=== CONT  TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists
=== CONT  TestAccECRRepositoryCreationTemplate_disappears
--- PASS: TestAccECRRepositoryCreationTemplate_failWhenAlreadyExists (6.64s)
=== CONT  TestAccECRRepositoryCreationTemplate_repository
--- PASS: TestAccECRRepositoryCreationTemplateDataSource_basic (10.10s)
=== CONT  TestAccECRRepositoryCreationTemplate_basic
--- PASS: TestAccECRRepositoryCreationTemplate_disappears (10.45s)
=== CONT  TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle
--- PASS: TestAccECRRepositoryCreationTemplate_basic (10.34s)
--- PASS: TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle (11.12s)
--- PASS: TestAccECRRepositoryCreationTemplate_repository (17.17s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	28.741s

@ewbankkit ewbankkit added new-resource Introduces a new resource. new-data-source Introduces a new data source. labels Jul 31, 2024
@ewbankkit
Copy link
Contributor

@bodgit Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 24bedfd into hashicorp:main Jul 31, 2024
56 checks passed
@github-actions github-actions bot added this to the v5.61.0 milestone Jul 31, 2024
@bodgit bodgit deleted the ecr-repository-creation-template branch July 31, 2024 21:21
@jef-rubert-hs
Copy link

jef-rubert-hs commented Aug 1, 2024

I am unable to create a ROOT aws_ecr_repository_creation_template because of this regex validation:

regexache.MustCompile(`(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*`),

root is different from ROOT as I can have both defined using the ui, one would make AWS look for a root repository and ROOT means apply to any.

as per ui

ROOT = 
Any prefix in your ECR registry
The settings in this template will be applied to all repositories that don't match another template in this Region.

vs

root = 
A specific prefix
The settings in this template will be applied to repositories matching the namespace prefix you specify.

this is the error I get:

╷
│ Error: invalid value for prefix (must only include alphanumeric, underscore, period, hyphen, or slash characters)
│
│   with aws_ecr_repository_creation_template.pull_through_cache_creation_template,
│   on ecr-pull-through-cache.tf line 81, in resource "aws_ecr_repository_creation_template" "pull_through_cache_creation_template":
│   81:   prefix               = "ROOT"
│
╵

edit: add error message
edit2: created issue: #38650

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 2, 2024
Copy link

github-actions bot commented Aug 2, 2024

This functionality has been released in v5.61.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!

Copy link

github-actions bot commented Sep 1, 2024

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 Sep 1, 2024
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. generators Relates to code generators. new-data-source Introduces a new data source. new-resource Introduces a new resource. service/ecr Issues and PRs that pertain to the ecr service. 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.

[New Resource]: ECR Repository Creation Template
3 participants