ERROR REFERENCE
Lambda does not have permission to access the ECR image
The container-image function was created or updated, but the Lambda service itself could not pull the image from ECR. This is about the repository letting Lambda in — not about your deploy role's permissions, which is why widening your own policy does nothing.
WHAT IT MEANS
What this error means
Lambda pulls the image with its own service principal, authorized by the ECR repository policy. Same-account pulls are normally wired up automatically when the function is created through CloudFormation or SAM; the failure shows up with cross-account repositories, repositories whose policy was replaced, or an image tag/digest that no longer exists.
FIX
How to fix it
-
Confirm the image reference still exists
(read-only):
A retagged or lifecycle-expired image produces this error with a perfectly healthy policy.aws ecr describe-images --repository-name my-repo --image-ids imageTag=latest -
Read the repository policy:
Lambda needsaws ecr get-repository-policy --repository-name my-repoecr:BatchGetImageandecr:GetDownloadUrlForLayergranted to thelambda.amazonaws.comservice principal — with source account/ARN conditions for cross-account setups. - For cross-account images, the repository owner adds that policy; the function owner cannot grant it from their side.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor recognizes this service-side pull failure (high confidence) and keeps it distinct from the CI runner's own ECR login failures. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- no basic auth credentials — the CI runner failing to push, the other half of the container path.
- Denied because no policy allows it — IAM-side denials, which name the missing action.