FunctionCode
The deployment package for a Lambda function.
Syntax
To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.
YAML
Bucket:StringKey:StringStorageMode:StringVersion:String
Properties
-
Bucket -
An Amazon S3 bucket in the same AWS Region as your function.
Type: String
Required: Yes
CloudFormation compatibility: This property is passed directly to the
S3Bucketproperty of theAWS::Lambda::FunctionCodedata type. -
Key -
The Amazon S3 key of the deployment package.
Type: String
Required: Yes
CloudFormation compatibility: This property is passed directly to the
S3Keyproperty of theAWS::Lambda::FunctionCodedata type. -
StorageMode -
Controls how Lambda stores the deployment package.
-
COPY– Lambda uploads a copy of your deployment package to Lambda-managed storage. You can delete the Amazon S3 object after Lambda creates the function. -
REFERENCE– Lambda references the deployment package from your Amazon S3 bucket and doesn't store a copy. The object must remain in place, and Lambda must keep access to it, for the lifetime of the function.
To use
REFERENCE, enable versioning on your Amazon S3 bucket and grant the Lambda service principal access to the object. For more information, see Self-managed Amazon S3 code storage in the AWS Lambda Developer Guide.Type: String
Valid values:
COPY|REFERENCERequired: No
Default:
COPYCloudFormation compatibility: This property is passed directly to the
S3ObjectStorageModeproperty of theAWS::Lambda::FunctionCodedata type. -
-
Version -
For versioned objects, the version of the deployment package object to use.
Type: String
Required: No
CloudFormation compatibility: This property is passed directly to the
S3ObjectVersionproperty of theAWS::Lambda::FunctionCodedata type.
Examples
FunctionCode
CodeUri: Function Code example
YAML
CodeUri: Bucket: sam-s3-demo-bucket-name Key: mykey-name Version: 121212
Self-managed Amazon S3 code storage
The following CodeUri references the deployment package from your own Amazon S3 bucket instead of copying it to Lambda-managed storage.
YAML
CodeUri: Bucket: amzn-s3-demo-bucket-name Key: mykey-name Version: 121212 StorageMode: REFERENCE