Skip to content

put_function_event_invoke_config async

put_function_event_invoke_config(
    function_name: NamespacedFunctionName,
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    qualifier: Optional[NumericLatestPublishedOrAliasQualifier] = None,
    maximum_retry_attempts: Optional[MaximumRetryAttempts] = None,
    maximum_event_age_in_seconds: Optional[MaximumEventAgeInSeconds] = None,
    destination_config: Optional[DestinationConfig] = None,
) -> FunctionEventInvokeConfig

Configures options for asynchronous invocation on a function, version, or alias. If a configuration already exists for a function, version, or alias, this operation overwrites it. If you exclude any settings, they are removed. To set one option without affecting existing settings for other options, use UpdateFunctionEventInvokeConfig.

By default, Lambda retries an asynchronous invocation twice if the function returns an error. It retains events in a queue for up to six hours. When an event fails all processing attempts or stays in the asynchronous invocation queue for too long, Lambda discards it. To retain discarded events, configure a dead-letter queue with UpdateFunctionConfiguration.

To send an invocation record to a queue, topic, S3 bucket, function, or event bus, specify a destination. You can configure separate destinations for successful invocations (on-success) and events that fail all processing attempts (on-failure). You can configure destinations in addition to or instead of a dead-letter queue.

S3 buckets are supported only for on-failure destinations. To retain records of successful invocations, use another destination type.

Parameters:

  • function_name (NamespacedFunctionName) –

    The name or ARN of the Lambda function, version, or alias.

    Name formats

    • Function name - my-function (name-only), my-function:v1 (with alias).

    • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:my-function.

    • Partial ARN - 123456789012:function:my-function.

    You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

  • qualifier (Optional[NumericLatestPublishedOrAliasQualifier], default: None ) –

    A version number or alias name.

  • maximum_retry_attempts (Optional[MaximumRetryAttempts], default: None ) –

    The maximum number of times to retry when the function returns an error.

  • maximum_event_age_in_seconds (Optional[MaximumEventAgeInSeconds], default: None ) –

    The maximum age of a request that Lambda sends to a function for processing.

  • destination_config (Optional[DestinationConfig], default: None ) –

    A destination for events after they have been sent to a function for processing.

    Destinations

    • Function - The Amazon Resource Name (ARN) of a Lambda function.

    • Queue - The ARN of a standard SQS queue.

    • Bucket - The ARN of an Amazon S3 bucket.

    • Topic - The ARN of a standard SNS topic.

    • Event Bus - The ARN of an Amazon EventBridge event bus.

    S3 buckets are supported only for on-failure destinations. To retain records of successful invocations, use another destination type.

Raises:

Examples:

To configure error handling for asynchronous invocation The following example sets a maximum event age of one hour and disables retries for the specified function.

>>> await client.put_function_event_invoke_config(function_name='my-function', maximum_event_age_in_seconds=3600, maximum_retry_attempts=0)
Source code in docs_src/capo_lambda/_services/async__lambda.py
async def put_function_event_invoke_config(
    self,
    function_name: "capo_lambda.types.namespaced_function_name.NamespacedFunctionName",
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    qualifier: Optional[
        "capo_lambda.types.numeric_latest_published_or_alias_qualifier.NumericLatestPublishedOrAliasQualifier"
    ] = None,
    maximum_retry_attempts: Optional[
        "capo_lambda.types.maximum_retry_attempts.MaximumRetryAttempts"
    ] = None,
    maximum_event_age_in_seconds: Optional[
        "capo_lambda.types.maximum_event_age_in_seconds.MaximumEventAgeInSeconds"
    ] = None,
    destination_config: Optional[
        "capo_lambda.types.destination_config.DestinationConfig"
    ] = None,
) -> "capo_lambda.types.function_event_invoke_config.FunctionEventInvokeConfig":
    """<p>Configures options for <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html">asynchronous invocation</a> on a function, version, or alias. If a configuration already exists for a function, version, or alias, this operation overwrites it. If you exclude any settings, they are removed. To set one option without affecting existing settings for other options, use <a>UpdateFunctionEventInvokeConfig</a>.</p> <p>By default, Lambda retries an asynchronous invocation twice if the function returns an error. It retains events in a queue for up to six hours. When an event fails all processing attempts or stays in the asynchronous invocation queue for too long, Lambda discards it. To retain discarded events, configure a dead-letter queue with <a>UpdateFunctionConfiguration</a>.</p> <p>To send an invocation record to a queue, topic, S3 bucket, function, or event bus, specify a <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-async-destinations">destination</a>. You can configure separate destinations for successful invocations (on-success) and events that fail all processing attempts (on-failure). You can configure destinations in addition to or instead of a dead-letter queue.</p> <note> <p>S3 buckets are supported only for on-failure destinations. To retain records of successful invocations, use another destination type.</p> </note>

    Args:
        function_name: <p>The name or ARN of the Lambda function, version, or alias.</p> <p class="title"> <b>Name formats</b> </p> <ul> <li> <p> <b>Function name</b> - <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p> </li> <li> <p> <b>Function ARN</b> - <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p> </li> <li> <p> <b>Partial ARN</b> - <code>123456789012:function:my-function</code>.</p> </li> </ul> <p>You can append a version number or alias to any of the formats. 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>
        qualifier: <p>A version number or alias name.</p>
        maximum_retry_attempts: <p>The maximum number of times to retry when the function returns an error.</p>
        maximum_event_age_in_seconds: <p>The maximum age of a request that Lambda sends to a function for processing.</p>
        destination_config: <p>A destination for events after they have been sent to a function for processing.</p> <p class="title"> <b>Destinations</b> </p> <ul> <li> <p> <b>Function</b> - The Amazon Resource Name (ARN) of a Lambda function.</p> </li> <li> <p> <b>Queue</b> - The ARN of a standard SQS queue.</p> </li> <li> <p> <b>Bucket</b> - The ARN of an Amazon S3 bucket.</p> </li> <li> <p> <b>Topic</b> - The ARN of a standard SNS topic.</p> </li> <li> <p> <b>Event Bus</b> - The ARN of an Amazon EventBridge event bus.</p> </li> </ul> <note> <p>S3 buckets are supported only for on-failure destinations. To retain records of successful invocations, use another destination type.</p> </note>

    Raises:
        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 configure error handling for asynchronous invocation
        The following example sets a maximum event age of one hour and disables retries for the specified function.

        >>> await client.put_function_event_invoke_config(function_name='my-function', maximum_event_age_in_seconds=3600, maximum_retry_attempts=0)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lambda.types.put_function_event_invoke_config_request.PutFunctionEventInvokeConfigRequest]",
    ) -> AsyncOperationResponse[
        "capo_lambda.types.function_event_invoke_config.FunctionEventInvokeConfig"
    ]:
        import capo_lambda._operations.aws_gir_api_service.put_function_event_invoke_config

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutFunctionEventInvokeConfig")
    )
    input_: capo_lambda.types.put_function_event_invoke_config_request.PutFunctionEventInvokeConfigRequest = {
        "function_name": function_name
    }
    if qualifier is not None:
        input_["qualifier"] = qualifier
    if maximum_retry_attempts is not None:
        input_["maximum_retry_attempts"] = maximum_retry_attempts
    if maximum_event_age_in_seconds is not None:
        input_["maximum_event_age_in_seconds"] = maximum_event_age_in_seconds
    if destination_config is not None:
        input_["destination_config"] = destination_config

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