Skip to content

create_alias

create_alias(
    function_name: FunctionName,
    name: Alias,
    function_version: VersionWithLatestPublished,
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    description: Optional[Description] = None,
    routing_config: Optional[AliasRoutingConfiguration] = None,
) -> AliasConfiguration

Creates an alias for a Lambda Event 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.

Parameters:

  • function_name (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.

  • name (Alias) –

    The name of the alias.

  • function_version (VersionWithLatestPublished) –

    The function version that the alias invokes.

  • description (Optional[Description], default: None ) –

    A description of the alias.

  • routing_config (Optional[AliasRoutingConfiguration], default: None ) –

    The routing configuration of the alias.

Raises:

Examples:

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

>>> client.create_alias(description='alias for live version of function', function_name='my-function', function_version='1', name='LIVE')
Source code in docs_src/capo_lambda/_services/_lambda.py
def create_alias(
    self,
    function_name: "capo_lambda.types.function_name.FunctionName",
    name: "capo_lambda.types.alias.Alias",
    function_version: "capo_lambda.types.version_with_latest_published.VersionWithLatestPublished",
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    description: Optional["capo_lambda.types.description.Description"] = None,
    routing_config: Optional[
        "capo_lambda.types.alias_routing_configuration.AliasRoutingConfiguration"
    ] = None,
) -> "capo_lambda.types.alias_configuration.AliasConfiguration":
    """<p>Creates an <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html">alias</a> for a Lambda Event Function version. Use aliases to provide clients with a function identifier that you can update to invoke a different version.</p> <p>You can also map an alias to split invocation requests between two versions. Use the <code>RoutingConfig</code> parameter to specify a second version and the percentage of invocation requests that it receives.</p>

    Args:
        function_name: <p>The name or ARN of the Lambda function.</p> <p class="title"> <b>Name formats</b> </p> <ul> <li> <p> <b>Function name</b> - <code>MyFunction</code>.</p> </li> <li> <p> <b>Function ARN</b> - <code>arn:aws:lambda:us-west-2:123456789012:function:MyFunction</code>.</p> </li> <li> <p> <b>Partial ARN</b> - <code>123456789012:function:MyFunction</code>.</p> </li> </ul> <p>The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
        name: <p>The name of the alias.</p>
        function_version: <p>The function version that the alias invokes.</p>
        description: <p>A description of the alias.</p>
        routing_config: <p>The <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html#configuring-alias-routing">routing configuration</a> of the alias.</p>

    Raises:
        capo_lambda.errors.alias_limit_exceeded_exception.AliasLimitExceededException: <p>Lambda couldn't create the alias because your Amazon Web Services account has exceeded the maximum number of aliases allowed per Lambda function. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">Lambda quotas</a>.</p>
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.resource_conflict_exception.ResourceConflictException: <p>The resource already exists, or another operation is in progress.</p>
        capo_lambda.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request does not exist.</p>
        capo_lambda.errors.service_exception.ServiceException: <p>The Lambda service encountered an internal error.</p>
        capo_lambda.errors.too_many_requests_exception.TooManyRequestsException: <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
        capo_lambda.errors.UnknownServiceError: The service returned an error code this client does not model.

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

        >>> client.create_alias(description='alias for live version of function', function_name='my-function', function_version='1', name='LIVE')
    """

    def _handler(
        req: "OperationRequest[capo_lambda.types.create_alias_request.CreateAliasRequest]",
    ) -> OperationResponse[
        "capo_lambda.types.alias_configuration.AliasConfiguration"
    ]:
        import capo_lambda._operations.aws_gir_api_service.create_alias

        output, http_response = (
            capo_lambda._operations.aws_gir_api_service.create_alias.create_alias(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAlias")
    )
    input_: capo_lambda.types.create_alias_request.CreateAliasRequest = {
        "function_name": function_name,
        "name": name,
        "function_version": function_version,
    }
    if description is not None:
        input_["description"] = description
    if routing_config is not None:
        input_["routing_config"] = routing_config

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output