Lambda deployment packages - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Lambda deployment packages

Your Amazon Lambda function's code consists of scripts or compiled programs and their dependencies. You use a deployment package to deploy your function code to Lambda. Lambda supports two types of deployment packages: container images and .zip file archives.

Container images

A container image includes the base operating system, the runtime, Lambda extensions, your application code and its dependencies. You can also add static data, such as machine learning models, into the image.

Lambda provides a set of open-source base images that you can use to build your container image. To create and test container images, you can use the Amazon Serverless Application Model (Amazon SAM) command line interface (CLI) or native container tools such as the Docker CLI.

Upload your container images to Amazon Elastic Container Registry (Amazon ECR), a managed Amazon container image registry service. To deploy the image to your function, specify the Amazon ECR image URL using the Lambda console, the Lambda API, command line tools, or the Amazon SDKs.

For more information about Lambda container images, see Working with Lambda container images.

.zip file archives

A .zip file archive includes your application code and its dependencies. When you author functions using the Lambda console or a toolkit, Lambda automatically creates a .zip file archive of your code.

When you create functions with the Lambda API, command line tools, or the Amazon SDKs, you must create a deployment package. You must also create a deployment package if your function uses a compiled language, or to add dependencies to your function. To deploy your function's code, upload the deployment package from Amazon Simple Storage Service (Amazon S3) or your local machine.

You can upload a .zip file as your deployment package using the Lambda console, Amazon Command Line Interface (Amazon CLI), or to an Amazon Simple Storage Service (Amazon S3) bucket.

Using the Lambda console

The following steps demonstrate how to upload a .zip file as your deployment package using the Lambda console.

To upload a .zip file on the Lambda console
  1. Open the Functions page on the Lambda console.

  2. Select a function.

  3. In the Code Source pane, choose Upload from and then .zip file.

  4. Choose Upload to select your local .zip file.

  5. Choose Save.

Using the Amazon CLI

You can upload a .zip file as your deployment package using the Amazon Command Line Interface (Amazon CLI). For language-specific instructions, see the following topics.

Node.js

Deploy Node.js Lambda functions with .zip file archives

Python

Working with .zip file archives for Python Lambda functions

Ruby

Working with .zip file archives for Ruby Lambda functions

Java

Deploy Java Lambda functions with .zip or JAR file archives

Go

Deploy Go Lambda functions with .zip file archives

C#

Build and deploy C# Lambda functions with .zip file archives

PowerShell

Deploy PowerShell Lambda functions with .zip file archives

Using Amazon S3

You can upload a .zip file as your deployment package using Amazon Simple Storage Service (Amazon S3). For more information, see Using other Amazon services to build a deployment package.

Layers

If you deploy your function code using a .zip file archive, you can use Lambda layers as a distribution mechanism for libraries, custom runtimes, and other function dependencies. Layers enable you to manage your in-development function code independently from the unchanging code and resources that it uses. You can configure your function to use layers that you create, layers that Amazon provides, or layers from other Amazon customers.

You can't use layers with container images. Instead, package your preferred runtime, libraries, and other dependencies into the container image when you build the image.

For more information about layers, see Working with Lambda layers.

Using other Amazon services to build a deployment package

The following section describes other Amazon services you can use to package dependencies for your Lambda function.

Deployment packages with C or C++ libraries

If your deployment package contains native libraries, you can build the deployment package with Amazon Serverless Application Model (Amazon SAM). You can use the Amazon SAM CLI sam build command with the --use-container to create your deployment package. This option builds a deployment package inside a Docker image that is compatible with the Lambda execution environment.

For more information, see sam build in the Amazon Serverless Application Model Developer Guide.

Deployment packages over 50 MB

If your deployment package is larger than 50 MB, upload your function code and dependencies to an Amazon S3 bucket.

You can create a deployment package and upload the .zip file to your Amazon S3 bucket in the Amazon Region where you want to create a Lambda function. When you create your Lambda function, specify the S3 bucket name and object key name on the Lambda console, or using the Amazon CLI.

To create a bucket using the Amazon S3 console, see Creating a bucket in the Amazon Simple Storage Service User Guide.