AWS CloudFormation
User Guide (Version )

AWS::Lambda::Version

The AWS::Lambda::Version resource creates a version from the current code and configuration of a function. Use versions to create a snapshot of your function code and configuration that doesn't change.

Syntax

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

JSON

{ "Type" : "AWS::Lambda::Version", "Properties" : { "CodeSha256" : String, "Description" : String, "FunctionName" : String } }

YAML

Type: AWS::Lambda::Version Properties: CodeSha256: String Description: String FunctionName: String

Properties

CodeSha256

Only publish a version if the hash value matches the value that's specified. Use this option to avoid publishing a version if the function code has changed since you last updated it.

Required: No

Type: String

Update requires: No interruption

Description

A description for the version to override the description in the function configuration.

Required: No

Type: String

Minimum: 0

Maximum: 256

Update requires: No interruption

FunctionName

The name of the Lambda function.

Name formats

  • Function name - MyFunction.

  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.

  • Partial ARN - 123456789012:function:MyFunction.

The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

Required: Yes

Type: String

Minimum: 1

Maximum: 140

Pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?

Update requires: Replacement

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ARN of the version, such as arn:aws:lambda:us-west-2:123456789012:function:helloworld:1.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Version

The version number.

Examples

Function Version

Create a version of function MyFunction.

JSON

"MyVersion": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { "Ref": "MyFunction" }, "Description": "A test version of MyFunction" } }

YAML

MyVersion: Type: AWS::Lambda::Version Properties: FunctionName: Ref: "MyFunction" Description: "A test version of MyFunction"