Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

plato-app/aws-lambda-update-action

 
 

Repository files navigation

AWS Lambda update action

GitHub GitHub release (latest by date) GitHub Workflow Status

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.

Usage

minimum

uses: kazimanzurrashid/[email protected]
with:
  zip-file: './dist/my_lambda.zip'

complete

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 Permission

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
    }
  ]
}

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.

Outputs

N/A

Examples

Node.js Lambda

name: API
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Node.js setup
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - 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

name: API
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Go setup
        uses: actions/setup-go@v3
        with:
          go-version: 1.19

      - 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

name: API
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: .NET setup
        uses: actions/setup-dotnet@v3
        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.

About

GitHub action that updates the given AWS Lambda.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%