AWS CloudFormation
User Guide (Version )
AWS services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with AWS services in China.

AWS::Lambda::Function Code

The deployment package for a Lambda function. For all runtimes, you can specify the location of an object in Amazon S3. For Node.js and Python functions, you can specify the function code inline in the template.

Changes to a deployment package in Amazon S3 are not detected automatically during stack updates. To update the function code, change the object key or version in the template.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "S3Bucket" : String, "S3Key" : String, "S3ObjectVersion" : String, "ZipFile" : String }

YAML

S3Bucket: String S3Key: String S3ObjectVersion: String ZipFile: String

Properties

S3Bucket

An Amazon S3 bucket in the same AWS Region as your function. The bucket can be in a different AWS account.

Required: Conditional

Type: String

Minimum: 3

Maximum: 63

Pattern: ^[0-9A-Za-z\.\-_]*(?<!\.)$

Update requires: No interruption

S3Key

The Amazon S3 key of the deployment package.

Required: Conditional

Type: String

Minimum: 1

Maximum: 1024

Update requires: No interruption

S3ObjectVersion

For versioned objects, the version of the deployment package object to use.

Required: Conditional

Type: String

Minimum: 1

Maximum: 1024

Update requires: No interruption

ZipFile

(Node.js and Python) The source code of your Lambda function. If you include your function source inline with this parameter, AWS CloudFormation places it in a file named index and zips it to create a deployment package. For the Handler property, the first part of the handler identifier must be index. For example, index.handler.

Your source code can contain up to 4096 characters. For JSON, you must escape quotes and special characters such as newline (\n) with a backslash.

If you specify a function that interacts with an AWS CloudFormation custom resource, you don't have to write your own functions to send responses to the custom resource that invoked the function. AWS CloudFormation provides a response module (cfn-response) that simplifies sending responses. See Using AWS Lambda with AWS CloudFormation for details.

Required: Conditional

Type: String

Update requires: No interruption

On this page: