AWS::Lambda::Version - AWS CloudFormation

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 CloudFormation template, use the following syntax:

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. Updates are not supported for this property.

Required: No

Type: String

Update requires: Replacement

Description

A description for the version to override the description in the function configuration. Updates are not supported for this property.

Required: No

Type: String

Minimum: 0

Maximum: 256

Update requires: Replacement

FunctionName

The name or ARN 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

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

Minimum: 1

Maximum: 140

Update requires: Replacement

FunctionScalingConfig

Configuration that defines the scaling behavior for a Lambda Managed Instances function, including the minimum and maximum number of execution environments that can be provisioned.

Required: No

Type: FunctionScalingConfig

Update requires: No interruption

ProvisionedConcurrencyConfig

Specifies a provisioned concurrency configuration for a function's version. Updates are not supported for this property.

Required: No

Type: ProvisionedConcurrencyConfiguration

Update requires: Replacement

RuntimePolicy

Property description not available.

Required: No

Type: RuntimePolicy

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-east-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.

FunctionArn

The ARN of the function.

Version

The version number.

Examples

Function Version

Publish a version with provisioned concurrency.

YAML

Resources:
  function:
    Type: AWS::Lambda::Function
    Properties:
      Handler: index.handler
      Role: arn:aws:iam::123456789012:role/lambda-role
      Code:
        ZipFile: |
          exports.handler = async (event) => {
              console.log(JSON.stringify(event, null, 2));
              const response = {
                  statusCode: 200,
                  body: JSON.stringify('Hello from Lambda!'),
              };
              return response;
          };
      Runtime: nodejs18.x
      TracingConfig:
        Mode: Active
  version:
    Type: AWS::Lambda::Version
    Properties:
      FunctionName: !Ref function
      Description: v1
      ProvisionedConcurrencyConfig:
        ProvisionedConcurrentExecutions: 20