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 Amazon CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::Lambda::Alias", "Properties" : { "Description" :String, "FunctionName" :String, "FunctionVersion" :String, "Name" :String, "ProvisionedConcurrencyConfig" :ProvisionedConcurrencyConfiguration, "RoutingConfig" :AliasRoutingConfiguration} }
YAML
Type: AWS::Lambda::Alias Properties: Description:StringFunctionName:StringFunctionVersion:StringName:StringProvisionedConcurrencyConfig:ProvisionedConcurrencyConfigurationRoutingConfig:AliasRoutingConfiguration
Properties
Description-
A description of the alias.
Required: No
Type: String
Minimum:
0Maximum:
256Update 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:
1Maximum:
140Pattern:
(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:
1Maximum:
1024Pattern:
(\$LATEST|[0-9]+)Update requires: No interruption
Name-
The name of the alias.
Required: Yes
Type: String
Minimum:
1Maximum:
128Pattern:
(?!^[0-9]+$)([a-zA-Z0-9-_]+)Update requires: Replacement
ProvisionedConcurrencyConfig-
Specifies a provisioned concurrency configuration for a function's alias.
Required: No
Type: ProvisionedConcurrencyConfiguration
Update requires: No interruption
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 Reffunction, Refreturns the resource ARN.
For more information about using the Reffunction, see Ref.
Examples
Alias
A Node.js function with a version and alias.
YAML
Resources: function: Type: AWS::Lambda::Function Properties: Handler: index.handler Role: arn:aws:iam::123456789012:role/lambda-role Code: ZipFile: | exports.handler = function(event){ console.log(JSON.stringify(event, null, 2)) const response = { statusCode: 200, body: JSON.stringify('Hello from Lambda!') } return response }; Runtime: nodejs12.x TracingConfig: Mode: Active version: Type: AWS::Lambda::Version Properties: FunctionName: !Ref function Description: v1 alias: Type: AWS::Lambda::Alias Properties: FunctionName: !Ref function FunctionVersion: !GetAtt version.Version Name: BLUE
Weighted Alias
An alias that routes requests to two versions.
YAML
Resources: function: Type: AWS::Lambda::Function Properties: Handler: index.handler Role: arn:aws:iam::123456789012:role/lambda-role Code: ZipFile: | exports.handler = function(event){ console.log(JSON.stringify(event, null, 2)) const response = { statusCode: 200, body: JSON.stringify('Hello again from Lambda!') } return response } Runtime: nodejs12.x TracingConfig: Mode: Active version: Type: AWS::Lambda::Version Properties: FunctionName: !Ref function Description: v1 newVersion: Type: AWS::Lambda::Version Properties: FunctionName: !Ref function Description: v2 alias: Type: AWS::Lambda::Alias Properties: FunctionName: !Ref function FunctionVersion: !GetAtt newVersion.Version Name: BLUE RoutingConfig: AdditionalVersionWeights: - FunctionVersion: !GetAtt version.Version FunctionWeight: 0.5