Automate Github push to AWS Lambda

Adnan Karol
2 min readAug 22, 2022

Suppose as a Data Scientist you create a model for performing a task. The codes are well documented on Github.

You also create a lambda function that is capable of using this model when it is triggered with an event.

AWS LAMBDA: “AWS Lambda is an event-driven, serverless computing system provided. It is a computing service that runs code in response and you dont need to manage the underlying resources.”

Now suppose after 1 months of time you notice that there is a small bug and you change the codes, and push them to GitHub. Is is not frustrating that you also need to change the corresponding lambda function ?

Well there exists a simple solution to automate this process using Github Actions.

GITHUB ACTIONS: “GitHub Actions is a CI/CD tool for the GitHub flow. You can use it to integrate and deploy code changes to a third-party cloud application platform as well as test, track, and manage code changes.”

How To

1. Create a folder .github and within that a folder named workflows, and within that a file main.yaml.

2. Copy the contents of the sample shown.

name: deploy to lambda
- main

name: deploy lambda from source
runs-on: ubuntu-latest
- name: checkout source code
uses: actions/checkout@v1
- name: default deploy
uses: appleboy/lambda-action@master
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: eu-central-1
function_name: test-data

3. You should configue the aws credentials within your github account for that repository. Settings -> Secrets -> Actions -> New repository secret.

4. You can create a new IAM user and get the access key ID and access ID, with limited permissions.

5. Provide the name of lambda at function_name, and the code which should be triggered at source. By default the Lambda function will search and execute the lambda_handler function. However this can be changed at the Lambda function console.

You can check for errors in the Actions tab of your GitHub repository page.

Thats all, once this is set-up, you can push changes to GitHub and it should automatically reflect in your Lambda Function.