SAM Doctor

ERROR REFERENCE

Denied because no policy allows it

An implicit deny: nothing blocks the action, but nothing grants it either. The error wording names the policy layer AWS expected the permission in — that is where the fix goes, as a least-privilege Allow for exactly the denied action and resource.

WHAT IT MEANS

What this error means

Modern IAM denial messages are precise about what was missing: ... is not authorized to perform: <action> on resource: <arn> because no identity-based policy allows the <action> action. The variants name different layers:

A wrong identity often masquerades as this failure: a deploy running under a different profile or role than intended is missing permissions it "should" have because it is not the principal you think it is.

FIX

How to fix it

  1. Confirm the identity first:
    aws sts get-caller-identity
    in the failing environment. If the account or role is not what you expected, fix the profile/role selection — not the policies.
  2. Grant the exact denied action on the exact resource in the policy layer the error names: the deploy role's identity policy, or the resource policy of the named bucket, key, or queue.
  3. Confirm the change with the IAM Policy Simulator before re-running the deployment — simulator runs are free and faster than deploy-retry loops.
  4. If it is unclear which policy applies, look up the denied event in CloudTrail (by request ID when the error includes one).
  5. Keep the grant least-privilege. Never attach AdministratorAccess to make a deployment pass.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes the no-policy-allows wording (high confidence), reports the denied action and expected policy layer from redacted evidence, and keeps explicit denies, OIDC failures, and ECR permission errors as their own findings. Runs locally; no AWS access, no log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED