Use CreateAlias with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CreateAlias with a CLI

The following code examples show how to use CreateAlias.

CLI
AWS CLI

To create an alias for a Lambda function

The following create-alias example creates an alias named LIVE that points to version 1 of the my-function Lambda function.

aws lambda create-alias \ --function-name my-function \ --description "alias for live version of function" \ --function-version 1 \ --name LIVE

Output:

{ "FunctionVersion": "1", "Name": "LIVE", "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE", "RevisionId": "873282ed-4cd3-4dc8-a069-d0c647e470c6", "Description": "alias for live version of function" }

For more information, see Configuring AWS Lambda Function Aliases in the AWS Lambda Developer Guide.

  • For API details, see CreateAlias in AWS CLI Command Reference.

PowerShell
Tools for PowerShell

Example 1: This example creates a New Lambda Alias for specified version and routing configuration to specify the percentage of invocation requests that it receives.

New-LMAlias -FunctionName "MylambdaFunction123" -RoutingConfig_AdditionalVersionWeight @{Name="1";Value="0.6} -Description "Alias for version 4" -FunctionVersion 4 -Name "PowershellAlias"
  • For API details, see CreateAlias in AWS Tools for PowerShell Cmdlet Reference.