SAM Doctor

ERROR REFERENCE

Requires capabilities : [CAPABILITY_IAM] (InsufficientCapabilitiesException)

CloudFormation refused the change set because your template creates or modifies IAM resources and the deployment did not explicitly acknowledge that. It is a consent check, not a permissions failure.

WHAT IT MEANS

What this error means

Templates that can change security posture — IAM roles, policies, users — require the caller to opt in with a capability flag. SAM templates hit this constantly because AWS::Serverless::Function generates an execution role behind the scenes. The error names exactly which acknowledgement is missing:

Note this failure is not IAM denying you anything. If the deploy identity actually lacked IAM permissions, you would see an AccessDenied error instead.

FIX

How to fix it

  1. Read which capability the error names and look at the IAM resources in the template first. The flag exists so someone confirms the IAM change is intended — do that confirmation, especially in shared accounts.
  2. Pass the smallest required capability for your tool:
    # SAM CLI
    sam deploy --capabilities CAPABILITY_IAM
    
    # samconfig.toml
    capabilities = "CAPABILITY_IAM"
    
    # AWS CLI
    aws cloudformation deploy --capabilities CAPABILITY_IAM
    
    # CDK bootstrap-managed deployments rarely hit this; raw cfn deploys do
    Use CAPABILITY_NAMED_IAM only when the template names IAM resources; both flags can be passed together when needed.
  3. For nested serverless applications, add CAPABILITY_AUTO_EXPAND and review the transformed template (aws cloudformation get-template --template-stage Processed) so you know what actually deploys.
  4. Re-run the deployment. If it now fails with a different IAM error, that is a real permissions problem, not a capability one.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes InsufficientCapabilitiesException and the Requires capabilities phrasing (high confidence) and distinguishes it from generic change-set failures. Runs locally; no AWS access, no log upload.

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

RELATED

Longer walkthrough: the capability acknowledgement guide.