Skip to content
Latchkey

How to Deploy API Gateway and Lambda With GitHub Actions

Update the backing Lambda, then publish the API to its stage with aws apigateway create-deployment.

After updating the Lambda code, promote the REST API changes to a stage with aws apigateway create-deployment --rest-api-id --stage-name. SAM or CloudFormation is cleaner for full provisioning; this targets an existing API.

Steps

  • Update the backing Lambda function code.
  • Authenticate to AWS over OIDC.
  • Run aws apigateway create-deployment for the REST API and stage.
  • Verify with a request to the stage invoke URL.

Workflow

.github/workflows/deploy.yml
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: zip -r function.zip index.js
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/gha-apigw-deploy
          aws-region: us-east-1
      - run: |
          aws lambda update-function-code \
            --function-name api-handler --zip-file fileb://function.zip
          aws apigateway create-deployment \
            --rest-api-id abc123xyz --stage-name prod

Gotchas

  • New routes or integrations require an API redeploy; a Lambda update alone is not enough.
  • HTTP APIs (v2) with auto-deploy stages do not need an explicit create-deployment call.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →