Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kazimanzurrashid/aws-lambda-update-action
GitHub action that updates the given AWS Lambda.
https://github.com/kazimanzurrashid/aws-lambda-update-action
action actions aws github-actions lambda
Last synced: 19 days ago
JSON representation
GitHub action that updates the given AWS Lambda.
- Host: GitHub
- URL: https://github.com/kazimanzurrashid/aws-lambda-update-action
- Owner: kazimanzurrashid
- License: mit
- Created: 2020-11-24T15:02:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T05:31:18.000Z (20 days ago)
- Last Synced: 2024-10-27T06:32:00.015Z (20 days ago)
- Topics: action, actions, aws, github-actions, lambda
- Language: TypeScript
- Homepage:
- Size: 10.1 MB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Lambda update action
[![GitHub](https://img.shields.io/github/license/kazimanzurrashid/aws-lambda-update-action)](https://opensource.org/licenses/MIT)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/kazimanzurrashid/aws-lambda-update-action)](https://github.com/kazimanzurrashid/aws-lambda-update-action/releases)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/kazimanzurrashid/aws-lambda-update-action/ci.yml)](https://github.com/kazimanzurrashid/aws-lambda-update-action/actions)This action updates a given lambda. It is very lightweight comparing to others, it uses the latest [AWS Node SDK 3](https://github.com/aws/aws-sdk-js-v3) which
only pulls lambda client to update the lambda code.## Usage
### minimum
```yaml
uses: kazimanzurrashid/[email protected]
with:
zip-file: './dist/my_lambda.zip'
```### complete
```yaml
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 }}
```## AWS Permission
The AWS Account needs to have the `"lambda:UpdateFunctionCode"` permission.
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["lambda:UpdateFunctionCode"],
"Resource": "*" // Don't use for production, change it to only your lambda name
}
]
}
```## Inputs
### `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.
## Outputs
N/A
## Examples
### Node.js Lambda
```yaml
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 }}
```### Go Lambda
```yaml
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 }}
```### .NET Lambda
```yaml
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 }}
```## License
This project is distributed under the [MIT license](LICENSE).