Tired of manually deploying your AWS lambda after every change? Let’s discuss how you can offload these responsibilities to a build automation tool, like Jenkins. Jenkins is able to deploy the latest version of your lambda with just a simple click of a button.

Deploying an AWS Lambda

In order to deploy an AWS lambda you must do the following:

  1. Create a deployment package
  2. Upload the deployment package to S3
  3. Upload deployment package to lambda

Prior to AWS’s announcement at re:Invent 2018, developers were unable to test their code locally. Therefore, you had to repeat these steps in order to test each iteration of your code. In the early stages of your development repeating these steps can be exhausting. We suggest deploying your lambdas using Jenkins or other build automation tools.

Creating and uploading a lambda deployment package

As discussed in our post about resolving an invalid elf header, the best way to create a deployment package is to spin up a docker container. Using a docker container prevents us from running into trivial errors when invoking our lambda, because we are installing our dependencies on the same system as which it runs. We should create a dockerfile to build our container and an entrypoint script to upload our deployment package. Prior to uploading the deployment package to S3, our entrypoint script should install any dependencies and zip up our source code.

See our lambda deploy GitHub repo for an example of how we create our dockerfile and entrypoint script.

Creating a Jenkins Pipeline

A Jenkins Pipeline is a continuous delivery (CD) pipeline that enables software to be deployed from your source control to your customers in seconds. With that being said, we want to create a Jenkins Pipeline to grab our source code from our repo and deploy it to AWS. In order to accomplish this, our pipeline must do the following:

  1. Grab our source code
  2. Spin up a docker container
  3. Install lambda dependencies
  4. Create deployment package
  5. Upload deployment package to S3
  6. Use Terraform or some other infrastructure as code (IaC) software to deploy our lambda

Visit our GitHub repo to see how we created a Jenkinsfile to deploy an AWS lambda.


Setting up your infrastructure to deploy an AWS lambda can take some time, but once in place it will simplify your deployment process and speed up your delivery. If you have questions with setting up your pipeline, please do not hesitate to contact us.

About the author