-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): Repository.fromRepositoryArn does not validate ARN which leads to wasted time #16223
Comments
Just ran into this myself. Would have been very confused if I had not found this issue. |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Arn validation would still be useful. |
This PR is adding a regex to check the `arn` structure of an ECR repository. Closes #16223 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
#25302 Actually breaks the scenario below at synth time:
Error: Repository arn should be in the format 'arn::ecr:::repository/', got dummy-value-for-/xxx/us-east-1/xx/xxx/EcrRepoArn. You can't validate the ARN at synth time. |
Ok, so the following code with the new CDK Pipelines produces an unexpected result:
The code will produce an error when running the pipeline:
error : [100%] fail: docker --config /tmp/cdkDockerConfignkKBqd build --tag cdkasset-699e5231c66d33f2bbdcd748964cd36874b9dc39c369f2f6d521381bd97afda0 . exited with error code 1: pull access denied for 1234567891234.dkr.ecr.eu-central-1.amazonaws.com/base-image-repo-from-ecr, repository does not exist or may require 'docker login': denied: User: arn:aws:sts::0987654376:assumed-role/PipelinePi-L9HGIT7CY91W/AWSCodeBuild-6054835c-9a09-4c3c-8f34-401787bd9553 is not authorized to perform: ecr:BatchGetImage on resource: arn:aws:ecr:eu-central-1:1234567891234:repository/base-image-repo-from-ecr
Can you spot the problem? Neither did I. So, I navigated to the ECR console to look for the ARN, but there are no ARNs. Googling ECR ARN produces AWS documentation page https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_Repository.html which does not have any ARNs.
After navigating to the IAM console, I see the following code which looks about right:
However, if you look very closely you can spot an error:
Ln 47, Col 24 Invalid ARN Resource: Resource ARN does not match the expected ARN format. Update the resource portion of the ARN. Learn more
.The learn more button leads to a page https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-reference-policy-checks.html#access-analyzer-reference-policy-checks-error-invalid-arn-resource which does not document what an ECR ARN looks like.
I proceed to launch a Cloud Shell and start learning AWS CLI. It looks like running
aws ecr describe-repositories
outputs the ARN format of the repositories.What did you expect to happen?
Maybe the repository name given for
ecr.Repository.fromRepositoryArn
could be validated at synth time.However, as you can see this waste of time was clearly caused by user error so feel free to close the ticket if you want :)
I'm documenting this here if anyone else runs to the same issue.
Environment
ECR ARN FORMAT
For future reference:
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: