AWS CloudFormation
User Guide (Version )

AWS::Lambda::Alias

The AWS::Lambda::Alias resource creates an alias for a Lambda function version. Use aliases to provide clients with a function identifier that you can update to invoke a different version.

You can also map an alias to split invocation requests between two versions. Use the RoutingConfig parameter to specify a second version and the percentage of invocation requests that it receives.

Syntax

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

JSON

{ "Type" : "AWS::Lambda::Alias", "Properties" : { "Description" : String, "FunctionName" : String, "FunctionVersion" : String, "Name" : String, "RoutingConfig" : AliasRoutingConfiguration } }

YAML

Type: AWS::Lambda::Alias Properties: Description: String FunctionName: String FunctionVersion: String Name: String RoutingConfig: AliasRoutingConfiguration

Properties

Description

A description of the alias.

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

FunctionVersion

The function version that the alias invokes.

Required: Yes

Type: String

Minimum: 1

Maximum: 1024

Pattern: (\$LATEST|[0-9]+)

Update requires: No interruption

Name

The name of the alias.

Required: Yes

Type: String

Minimum: 1

Maximum: 128

Pattern: (?!^[0-9]+$)([a-zA-Z0-9-_]+)

Update requires: Replacement

RoutingConfig

The routing configuration of the alias.

Required: No

Type: AliasRoutingConfiguration

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource ARN.

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

Examples

Alias

Create an alias named PROD that maps to a version created in the same template.

JSON

"AliasForMyApp": { "Type": "AWS::Lambda::Alias", "Properties": { "FunctionName": { "Ref": "MyFunction" }, "FunctionVersion": { "Fn::GetAtt": [ "MyVersion", "Version" ] }, "Name": "PROD" } }

YAML

AliasForMyApp: Type: AWS::Lambda::Alias Properties: FunctionName: Ref: "MyFunction" FunctionVersion: Fn::GetAtt: - "TestingNewFeature" - "Version" Name: "TestingForMyApp"