Skip to content

Python AWS Lambda Deployment

Actions
Deploy python code to AWS Lambda with dependencies in a separate layer along with custom python version
v1.0
Latest
Star (0)

Tags

 (1)

Python AWS Lambda Deploy

GitHubActions

A GitHub Action to deploy AWS Lambda functions written in Python, allowing you to specify any Python version supported by Lambda. Dependencies are packaged in a separate Lambda layer.

Features

  • Supports custom Python versions (e.g., 3.7, 3.8, 3.9, 3.10 ...)
  • Packages dependencies into a Lambda layer
  • Deploys Lambda code and updates the function to use the new layer
⚠️ Warning
This doesn't work with numpy library. For numpy library layer setup check here

Prerequisites

Use actions/checkout before this action to pull your code.

Structure

  • Lambda code in the root of your repo or subdirectory as you usually deploy.
  • Dependencies listed in a requirements.txt (or another file you specify).

Inputs

Input Description Default
lambda_layer_arn ARN of the Lambda layer (without version)
lambda_function_name Lambda function name or ARN
requirements_txt Path to your requirements.txt file requirements.txt
python_version Python version to use for building dependencies (e.g., 3.9) 3.12

Example workflow

name: deploy-py-lambda
on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - name: Deploy code to Lambda
      uses: arthiondaena/py-lambda-deploy@v1.0
      with:
        lambda_layer_arn: 'arn:aws:lambda:us-east-1:123445678987:layer:Hello_world2'
        lambda_function_name: 'arn:aws:lambda:us-east-1:123445678987:function:Hello_world_2'
        python_version: '3.10'
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_DEFAULT_REGION: 'us-east-1'

Python AWS Lambda Deployment is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Deploy python code to AWS Lambda with dependencies in a separate layer along with custom python version
v1.0
Latest

Tags

 (1)

Python AWS Lambda Deployment is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.