Lambda / Client / create_alias

create_alias#

Lambda.Client.create_alias(**kwargs)#

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.

See also: AWS API Documentation

Request Syntax

response = client.create_alias(
    FunctionName='string',
    Name='string',
    FunctionVersion='string',
    Description='string',
    RoutingConfig={
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
)
Parameters:
  • FunctionName (string) –

    [REQUIRED]

    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.

  • Name (string) –

    [REQUIRED]

    The name of the alias.

  • FunctionVersion (string) –

    [REQUIRED]

    The function version that the alias invokes.

  • Description (string) – A description of the alias.

  • RoutingConfig (dict) –

    The routing configuration of the alias.

    • AdditionalVersionWeights (dict) –

      The second version, and the percentage of traffic that’s routed to it.

      • (string) –

        • (float) –

Return type:

dict

Returns:

Response Syntax

{
    'AliasArn': 'string',
    'Name': 'string',
    'FunctionVersion': 'string',
    'Description': 'string',
    'RoutingConfig': {
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    },
    'RevisionId': 'string'
}

Response Structure

  • (dict) –

    Provides configuration information about a Lambda function alias.

    • AliasArn (string) –

      The Amazon Resource Name (ARN) of the alias.

    • Name (string) –

      The name of the alias.

    • FunctionVersion (string) –

      The function version that the alias invokes.

    • Description (string) –

      A description of the alias.

    • RoutingConfig (dict) –

      The routing configuration of the alias.

      • AdditionalVersionWeights (dict) –

        The second version, and the percentage of traffic that’s routed to it.

        • (string) –

          • (float) –

    • RevisionId (string) –

      A unique identifier that changes when you update the alias.

Exceptions

  • Lambda.Client.exceptions.ServiceException

  • Lambda.Client.exceptions.ResourceNotFoundException

  • Lambda.Client.exceptions.ResourceConflictException

  • Lambda.Client.exceptions.InvalidParameterValueException

  • Lambda.Client.exceptions.TooManyRequestsException

Examples

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

response = client.create_alias(
    Description='alias for live version of function',
    FunctionName='my-function',
    FunctionVersion='1',
    Name='LIVE',
)

print(response)

Expected Output:

{
    'AliasArn': 'arn:aws:lambda:us-east-2:123456789012:function:my-function:LIVE',
    'Description': 'alias for live version of function',
    'FunctionVersion': '1',
    'Name': 'LIVE',
    'RevisionId': '873282ed-xmpl-4dc8-a069-d0c647e470c6',
    'ResponseMetadata': {
        '...': '...',
    },
}