Skip to content

update_alias async

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

Updates the configuration of a Lambda Event Function alias.

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 (Optional[VersionWithLatestPublished], default: None ) –

    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.

  • revision_id (Optional[String], default: None ) –

    Only update the alias if the revision ID matches the ID that's specified. Use this option to avoid modifying an alias that has changed since you last read it.

Raises:

  • InvalidParameterValueException –

    One of the parameters in the request is not valid.

  • PreconditionFailedException –

    The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.

    • For AddPermission and RemovePermission API operations: Call GetPolicy to retrieve the latest RevisionId for your resource.

    • For all other API operations: Call GetFunction or GetAlias to retrieve the latest RevisionId for your resource.

  • ResourceConflictException –

    The resource already exists, or another operation is in progress.

  • ResourceNotFoundException –

    The resource specified in the request does not exist.

  • ServiceException –

    The Lambda service encountered an internal error.

  • TooManyRequestsException –

    The request throughput limit was exceeded. For more information, see Lambda quotas.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To update a function alias The following example updates the alias named BLUE to send 30% of traffic to version 2 and 70% to version 1.

>>> await client.update_alias(function_name='my-function', function_version='2', name='BLUE', routing_config={'AdditionalVersionWeights': {'1': 0.7}})
Source code in docs_src/capo_lambda/_services/async__lambda.py
async def update_alias(
    self,
    function_name: "capo_lambda.types.function_name.FunctionName",
    name: "capo_lambda.types.alias.Alias",
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    function_version: Optional[
        "capo_lambda.types.version_with_latest_published.VersionWithLatestPublished"
    ] = None,
    description: Optional["capo_lambda.types.description.Description"] = None,
    routing_config: Optional[
        "capo_lambda.types.alias_routing_configuration.AliasRoutingConfiguration"
    ] = None,
    revision_id: Optional["capo_lambda.types.string.String"] = None,
) -> "capo_lambda.types.alias_configuration.AliasConfiguration":
    """<p>Updates the configuration of a Lambda Event Function <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html">alias</a>.</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>
        revision_id: <p>Only update the alias if the revision ID matches the ID that's specified. Use this option to avoid modifying an alias that has changed since you last read it.</p>

    Raises:
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.precondition_failed_exception.PreconditionFailedException: <p>The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.</p> <ul> <li> <p> <b>For AddPermission and RemovePermission API operations:</b> Call <code>GetPolicy</code> to retrieve the latest RevisionId for your resource.</p> </li> <li> <p> <b>For all other API operations:</b> Call <code>GetFunction</code> or <code>GetAlias</code> to retrieve the latest RevisionId for your resource.</p> </li> </ul>
        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 update a function alias
        The following example updates the alias named BLUE to send 30% of traffic to version 2 and 70% to version 1.

        >>> await client.update_alias(function_name='my-function', function_version='2', name='BLUE', routing_config={'AdditionalVersionWeights': {'1': 0.7}})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lambda.types.update_alias_request.UpdateAliasRequest]",
    ) -> AsyncOperationResponse[
        "capo_lambda.types.alias_configuration.AliasConfiguration"
    ]:
        import capo_lambda._operations.aws_gir_api_service.update_alias

        (
            output,
            http_response,
        ) = await capo_lambda._operations.aws_gir_api_service.update_alias.async_update_alias(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output