-
Notifications
You must be signed in to change notification settings - Fork 4k
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
codepipeline_actions.EcsDeployAction: CannotPullContainerError: 403 Forbidden #29876
Comments
@harrison-traintobecome Good morning. Apologies for delayed reply. Could you please confirm if your CDK deployment is in a private VPC? If yes, do you have VPCE Endpoint configured for EKS service? Thanks, |
The stack that contains the ecs defintion is as follows:
If this^ is not what you meant, could you please clarify? I have not manually setup any EKS or ECS Vpce Endpoints. |
@harrison-traintobecome Good afternoon. Apologies for delayed reply. Could you please confirm if you are able to resolve the issue? From the error message, it appears IAM permission related issue most likely thrown by Docker command in Thanks, |
Thanks for the response, this remains unresolved. I can confirm that the issue does not lie in the buildspac.yml as the "images.json" output artifact exists and is properly formatted. The example repository mentioned ( https://github.com/aws-samples/amazon-ecs-anywhere-cicd-pipeline-cdk-sample) was referenced heavily to make my CDK code. Thanks, |
@harrison-traintobecome Thanks for the reply. Could you also your Amazon ECR repository policy for restrictions on accessing the repository (reference blog post https://repost.aws/knowledge-center/ecs-pull-container-api-error-ecr). In the mean while, I'm trying end-to-end example at my end. Thanks, |
Yes, I grant the necessary ECR permissions here "app_ui_repo.grant_pull_push(code_pipeline_service_role)" - and have tried granting the EcsDeployRole and CodepipelineServiceRole admin access. |
@harrison-traintobecome I'm referring to any IAM policy at ECR repository level that restricts access. IAM role might have access, but ECR repository might have IAM policy that restricts access. |
No, all permissions pertaining to the ECR repository are defined in the CDK and there are no other policies attached. |
The error
indicates a 403 Forbidden error when attempting to pull an image from Amazon Elastic Container Registry (ECR) during an Amazon Elastic Container Service (ECS) CI/CD pipeline deployment. An ECS CI/CD pipeline typically consists of the following stages: Source Stage - Triggers the pipeline and retrieves the source code. The ECS control plane then triggers a rolling update of tasks, and the ECS Task Execution Role attempts to pull the new container image specified in the updated Task Definition. This is the only stage where ECR image pulling occurs. Things to check:
If unsure, feel free to share your policies for further assistance. Relevant AWS documentation:Amazon ECR Repositories |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
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. |
Describe the bug
I have a ECS service that I want to deploy through a CI/CD pipeline, the pipeline deploys and builds everything fine. The EcsDeployAction times out, upon inspection in the console, the latest, stopped, task container shows an error:
Task stopped at: 2024-04-17T20:43:16.177Z
CannotPullContainerError: pull image manifest has been retried 1 time(s): failed to resolve ref 123456789123.dkr.ecr.us-east-1.amazonaws.com/a2-ecr-app-repo:latest: pulling from host 123456789123.dkr.ecr.us-east-1.amazonaws.com failed with status code [manifests latest]: 403 Forbidden
The specified image is present in the specified ECR repository, I have tried adding admin permissions to the EcsDeployAction's role and the Codepipeline's service role, as well as making the ECR repository's images public to all resources in my account.
Relevent CDK code:
Buildspec.yml in the source repository:
Expected Behavior
Codepipeline to successfully deploy/update the Ecs service.
Current Behavior
The Codepipeline fails on the EcsDeployAction step.
Reproduction Steps
Due to the nature of CI/CD pipelines, it is hard to make a copy and paste-able snippet, but here is everything you need to do to setup this repo:
Possible Solution
May be a python issue, the typescript ECS/Codepipeline repos seam to be working fine
Additional Information/Context
Common issues I have ruled out:
CDK CLI Version
2.108.0 (build 5665a95)
Framework Version
No response
Node.js Version
v18.17.1
OS
Amazon Linux 2
Language
Python
Language Version
Python 3.8.16
Other information
No response
The text was updated successfully, but these errors were encountered: