Skip to content

Add CAPABILITY_IAM to SAM deploy in GitHub Actions workflow - #15

Merged
Stealinglight merged 2 commits into
mainfrom
copilot/fix-capability-iam-deployment
Jan 19, 2026
Merged

Stealinglight merged 2 commits into
mainfrom
copilot/fix-capability-iam-deployment

Conversation

Copilot AI commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

CloudFormation deployment fails with "Requires capabilities : [CAPABILITY_IAM]" because the template creates IAM execution roles for Lambda but the deploy command doesn't acknowledge this capability.

Changes

  • Added --capabilities CAPABILITY_IAM flag to sam deploy command in .github/workflows/deploy-lambda.yml

The flag placement follows AWS SAM best practices, positioned after changeset options and before parameter overrides:

sam deploy \
  --stack-name ${{ github.event.inputs.stack_name || 'strava-mcp-stack' }} \
  --resolve-s3 \
  --no-confirm-changeset \
  --no-fail-on-empty-changeset \
  --capabilities CAPABILITY_IAM \
  --parameter-overrides \
    StravaClientId=${{ secrets.STRAVA_CLIENT_ID }} \
    ...

This authorizes CloudFormation to create IAM resources defined in template.yaml (specifically the Lambda execution role from AWS::Serverless::Function).

Original prompt

The job failed due to a missing capability when deploying the AWS CloudFormation stack. The log shows:

Error: Failed to create changeset for the stack: strava-mcp-stack, ex: Waiter ChangeSetCreateComplete failed... Reason: Requires capabilities : [CAPABILITY_IAM...]

Solution:
You must specify the required capability when deploying resources that create or modify IAM roles/policies. In your workflow .github/workflows/deploy-lambda.yml, update the "SAM Deploy" step’s command to include this flag:

sam deploy \
  --stack-name ${{ github.event.inputs.stack_name || 'strava-mcp-stack' }} \
  --resolve-s3 \
  --no-confirm-changeset \
  --no-fail-on-empty-changeset \
  --capabilities CAPABILITY_IAM \
  --parameter-overrides \
    StravaClientId=${{ secrets.STRAVA_CLIENT_ID }} \
    StravaClientSecret=${{ secrets.STRAVA_CLIENT_SECRET }} \
    StravaRefreshToken=${{ secrets.STRAVA_REFRESH_TOKEN }}

Add the --capabilities CAPABILITY_IAM line after --no-fail-on-empty-changeset in the deploy command. This allows CloudFormation to create/update IAM resources, resolving the terminal failure.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Stealinglight <120747552+Stealinglight@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing IAM capability in CloudFormation deployment Add CAPABILITY_IAM to SAM deploy in GitHub Actions workflow Jan 19, 2026
Copilot AI requested a review from Stealinglight January 19, 2026 05:13
@Stealinglight
Stealinglight marked this pull request as ready for review January 19, 2026 05:14
@claude

claude Bot commented Jan 19, 2026

Copy link
Copy Markdown

No issues found. Checked for bugs and CLAUDE.md compliance.

@Stealinglight
Stealinglight merged commit af4c1e2 into main Jan 19, 2026
1 of 2 checks passed
@Stealinglight
Stealinglight deleted the copilot/fix-capability-iam-deployment branch January 19, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址