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

AWS ECR: error (AccessDeniedException) calling CreateRepository #120

Closed
benjimin opened this issue Jan 14, 2023 · 2 comments · Fixed by #121
Closed

AWS ECR: error (AccessDeniedException) calling CreateRepository #120

benjimin opened this issue Jan 14, 2023 · 2 comments · Fixed by #121
Assignees
Labels
bug Something isn't working

Comments

@benjimin
Copy link

benjimin commented Jan 14, 2023

If this action is not granted the ecr:CreateRepository permission, then the following error message is emitted twice on each run:

An error occurred (AccessDeniedException) when calling the CreateRepository operation: User[..] is not authorized to perform: ecr:CreateRepository on resource: [..] because no identity-based policy allows the ecr:CreateRepository action

It is documented (e.g. in v6) that, for ECR, "You don't even need to create the repositories in advance, as this action takes care of that for you!"

However, the action shouldn't need permission to create the repository, if it already exists.

If the action does attempt to create the repositories, without checking whether they already exist, then it should only print a warning if creation fails (instead of an error), because the log should not be cluttered with "errors" that are safe to ignore. Otherwise these messages mislead the debugging of actual errors (such as blank tag names, for example). Note that if the repositories don't already exist then there will be an actual error at a later stage.

As an aside, the creation capability is suggestive of giving an entire github account carte blanche access across ECR, whereas best practice dictates that the permissions granted to each github repo action should be scoped to only the resources it needs. Otherwise a malicious commit in one repo could compromise stable images that are usually derived from completely separate (and better guarded) repos. So it would be inadvisable not to configure each AWS ECR repo individually (and the action ought not already have permission to create the repo before then). Hence the importance of the messaging surrounding repo creation.

@soronpo
Copy link

soronpo commented Jan 17, 2023

I also hit this issue

@whoan
Copy link
Owner

whoan commented Jan 18, 2023

@benjimin @soronpo I have this in my queue. I think I know how to improve the action to avoid the permission to create the repo when that's not needed. Just waiting to have some time.
Thanks for reporting the issue.

@whoan whoan self-assigned this Jan 18, 2023
@whoan whoan added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants