GitHub action that updates the given AWS Lambda.
MIT License
This action updates a given lambda. It is very lightweight comparing to others, it uses the latest AWS Node SDK 3 which only pulls lambda client to update the lambda code.
uses: kazimanzurrashid/[email protected]
with:
zip-file: './dist/my_lambda.zip'
uses: kazimanzurrashid/[email protected]
with:
zip-file: './dist/my_lambda.zip'
lambda-name: 'your_lambda'
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
The AWS Account needs to have the "lambda:UpdateFunctionCode"
permission.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["lambda:UpdateFunctionCode"],
"Resource": "*" // Don't use for production, change it to only your lambda name
}
]
}
zip-file
Required. The zip location, this is the only required argument of this action.
lambda-name
Optional. If not specified. it takes the zip file base name as lambda name. (e.g. if the zip file is my_lambda.zip
it would update my_lambda
lambda)
AWS_REGION
Optional, if not specified fallbacks to environment variable.
AWS_ACCESS_KEY_ID
Optional, if not specified fallbacks to environment variable.
AWS_SECRET_ACCESS_KEY
Optional, if not specified fallbacks to environment variable.
AWS_SESSION_TOKEN
Optional, if not specified fallbacks to environment variable.
N/A
name: API
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node.js setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
npm ci
npm run pack
cd dist && zip -r -9 api.zip *
- name: Update
uses: kazimanzurrashid/[email protected]
with:
zip-file: dist/api.zip
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: API
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Go setup
uses: actions/setup-go@v5
with:
go-version: 1.20
- name: Build
run: |
go get -v -t -d ./...
mkdir dist
CGO_ENABLED=0 go build -o dist/main
cd dist && zip -r -9 api.zip *
- name: Update
uses: kazimanzurrashid/[email protected]
with:
zip-file: dist/api.zip
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: API
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: .NET setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6
- name: Lambda.Tools install
run: dotnet tool install -g Amazon.Lambda.Tools
- name: Build
run: |
cd src/Api
dotnet lambda package -o api.zip
- name: Update
uses: kazimanzurrashid/[email protected]
with:
zip-file: src/Api/api.zip
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
This project is distributed under the MIT license.