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

fix(apprunner): auto deployment fails after new container image pushed due to lack of a permission #30630

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

mazyu36
Copy link
Contributor

@mazyu36 mazyu36 commented Jun 23, 2024

Issue # (if applicable)

Closes #26640

Reason for this change

According to the docs, required permissions for an App Runner's AccessRole to access images in ECR repository are the followings:

  1. "ecr:GetDownloadUrlForLayer",
  2. "ecr:BatchCheckLayerAvailability",
  3. "ecr:BatchGetImage",
  4. "ecr:DescribeImages",
  5. "ecr:GetAuthorizationToken"

No.1~3 are granted by the grantPull method of ecr.Repository.

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-apprunner-alpha/lib/service.ts#L1303

Permission for No.5 is granted by the following.
Note : It is correct that the resources here is set to *(Ref: docs)

If you create your own custom policy for your access role, be sure to specify "Resource": "*" for the ecr:GetAuthorizationToken action. Tokens can be used to access any Amazon ECR registry that you have access to.

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-apprunner-alpha/lib/service.ts#L1368

At the moment, No.4 permission is missing. So we need to add.

Description of changes

Add a ecr:DescribeImages permisison to the AccessRole.

Description of how you validated changes

Update a unit test and a integ test.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added star-contributor [Pilot] contributed between 25-49 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Jun 23, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team June 23, 2024 07:16
@mazyu36 mazyu36 changed the title fix(apprunner): auto deployment fails after new image due to lack of a permission fix(apprunner): auto deployment fails after new container image pushed due to lack of a permission Jun 23, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@mazyu36 mazyu36 force-pushed the apprunner-deploy-ecr-26640 branch from 9e87111 to 1e922b8 Compare June 23, 2024 07:26
@aws-cdk-automation aws-cdk-automation dismissed their stale review June 23, 2024 07:28

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 23, 2024
@mazyu36 mazyu36 force-pushed the apprunner-deploy-ecr-26640 branch from 1e922b8 to 54a1b58 Compare June 23, 2024 10:15
Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

Looks good!

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Jun 23, 2024
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for contributing.

Copy link
Contributor

mergify bot commented Jun 25, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 06c3b5c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit cce10b1 into aws:main Jun 25, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Jun 25, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mazyu36 mazyu36 deleted the apprunner-deploy-ecr-26640 branch June 26, 2024 14:32
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apprunner: After pushing a Docker image to ECR, isn't triggered.
4 participants