aws-cdk-lib.aws_lambda.EventInvokeConfig

class EventInvokeConfig (construct)

LanguageType name
.NETAmazon.CDK.AWS.Lambda.EventInvokeConfig
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#EventInvokeConfig
Javasoftware.amazon.awscdk.services.lambda.EventInvokeConfig
Pythonaws_cdk.aws_lambda.EventInvokeConfig
TypeScript (source)aws-cdk-lib » aws_lambda » EventInvokeConfig

Implements IConstruct, IDependable, IResource

Configure options for asynchronous invocation on a version or an alias.

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.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';

declare const destination: lambda.IDestination;
declare const function_: lambda.Function;
const eventInvokeConfig = new lambda.EventInvokeConfig(this, 'MyEventInvokeConfig', {
  function: function_,

  // the properties below are optional
  maxEventAge: cdk.Duration.minutes(30),
  onFailure: destination,
  onSuccess: destination,
  qualifier: 'qualifier',
  retryAttempts: 123,
});

Initializer

new EventInvokeConfig(scope: Construct, id: string, props: EventInvokeConfigProps)

Parameters

  • scope Construct
  • id string
  • props EventInvokeConfigProps

Construct Props

NameTypeDescription
functionIFunctionThe Lambda function.
maxEventAge?DurationThe maximum age of a request that Lambda sends to a function for processing.
onFailure?IDestinationThe destination for failed invocations.
onSuccess?IDestinationThe destination for successful invocations.
qualifier?stringThe qualifier.
retryAttempts?numberThe maximum number of times to retry when the function returns an error.

function

Type: IFunction

The Lambda function.


maxEventAge?

Type: Duration (optional, default: Duration.hours(6))

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

Minimum: 60 seconds Maximum: 6 hours


onFailure?

Type: IDestination (optional, default: no destination)

The destination for failed invocations.


onSuccess?

Type: IDestination (optional, default: no destination)

The destination for successful invocations.


qualifier?

Type: string (optional, default: latest version)

The qualifier.


retryAttempts?

Type: number (optional, default: 2)

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

Minimum: 0 Maximum: 2

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.