CodexBloom - Programming Q&A Platform

Trouble Setting Up AWS App Runner with Docker Image from ECR - 403 Forbidden Error

👀 Views: 88 đŸ’Ŧ Answers: 1 📅 Created: 2025-09-06
aws docker ecr app-runner bash

Can someone help me understand I'm confused about I'm trying to set up an AWS App Runner service using a Docker image hosted on Amazon ECR, but I keep running into a `403 Forbidden` error when deploying the service. I've followed the steps to create an ECR repository and pushed my Docker image correctly... Here's how I created the repository and pushed the image: ```bash aws ecr create-repository --repository-name my-app $(aws ecr get-login --no-include-email --region us-west-2) # Assuming my Dockerfile is in the current directory docker build -t my-app . docker tag my-app:latest <account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app:latest docker push <account-id>.dkr.ecr.us-west-2.amazonaws.com/my-app:latest ``` After that, I created the App Runner service via the console and provided the ECR image URL. However, when I try to deploy, I see this error in the App Runner logs: ``` ERROR: Failed to pull image: AccessDeniedException: User: arn:aws:sts::<account-id>:assumed-role/AppRunnerServiceRole-<random-string>/app-runner is not authorized to perform: ecr:GetAuthorizationToken on resource: * ``` I've checked the IAM role that App Runner is using (AppRunnerServiceRole-<random-string>), and it seems to have the following policy attached: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecr:BatchGetImage", "ecr:BatchCheckLayerAvailability", "ecr:GetAuthorizationToken", "ecr:DescribeRepositories" ], "Resource": "*" } ] } ``` I thought the `ecr:GetAuthorizationToken` permission was enough, but it seems that it's not working. I've also tried creating a new role with broader permissions but still face the same issue. Is there something I'm missing with the IAM policies or the way App Runner interacts with ECR? Any insights or troubleshooting steps would be greatly appreciated! For context: I'm using Bash on macOS. Any ideas what could be causing this? This is happening in both development and production on Ubuntu 20.04. I'd love to hear your thoughts on this. I'd really appreciate any guidance on this.