aws-cdk-lib.triggers.Trigger

class Trigger (construct)

LanguageType name
.NETAmazon.CDK.Triggers.Trigger
Gogithub.com/aws/aws-cdk-go/awscdk/v2/triggers#Trigger
Javasoftware.amazon.awscdk.triggers.Trigger
Pythonaws_cdk.triggers.Trigger
TypeScript (source)aws-cdk-lib » triggers » Trigger

Implements IConstruct, IDependable, ITrigger

Triggers an AWS Lambda function during deployment.

Example

import * as triggers from 'aws-cdk-lib/triggers';

const func = new lambda.Function(this, 'MyFunction', {
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_14_X,
  code: lambda.Code.fromInline('foo'),
});

new triggers.Trigger(this, 'MyTrigger', {
  handler: func,
  timeout: Duration.minutes(10),
  invocationType: triggers.InvocationType.EVENT,
});

Initializer

new Trigger(scope: Construct, id: string, props: TriggerProps)

Parameters

  • scope Construct
  • id string
  • props TriggerProps

Construct Props

NameTypeDescription
handlerFunctionThe AWS Lambda function of the handler to execute.
executeAfter?Construct[]Adds trigger dependencies. Execute this trigger only after these construct scopes have been provisioned.
executeBefore?Construct[]Adds this trigger as a dependency on other constructs.
executeOnHandlerChange?booleanRe-executes the trigger every time the handler changes.
invocationType?InvocationTypeThe invocation type to invoke the Lambda function with.
timeout?DurationThe timeout of the invocation call of the Lambda function to be triggered.

handler

Type: Function

The AWS Lambda function of the handler to execute.


executeAfter?

Type: Construct[] (optional, default: [])

Adds trigger dependencies. Execute this trigger only after these construct scopes have been provisioned.

You can also use trigger.executeAfter() to add additional dependencies.


executeBefore?

Type: Construct[] (optional, default: [])

Adds this trigger as a dependency on other constructs.

This means that this trigger will get executed before the given construct(s).

You can also use trigger.executeBefore() to add additional dependants.


executeOnHandlerChange?

Type: boolean (optional, default: true)

Re-executes the trigger every time the handler changes.

This implies that the trigger is associated with the currentVersion of the handler, which gets recreated every time the handler or its configuration is updated.


invocationType?

Type: InvocationType (optional, default: RequestResponse)

The invocation type to invoke the Lambda function with.


timeout?

Type: Duration (optional, default: Duration.minutes(2))

The timeout of the invocation call of the Lambda function to be triggered.

Properties

NameTypeDescription
nodeNodeThe tree node.

node

Type: Node

The tree node.

Methods

NameDescription
executeAfter(...scopes)Adds trigger dependencies.
executeBefore(...scopes)Adds this trigger as a dependency on other constructs.
toString()Returns a string representation of this construct.

executeAfter(...scopes)

public executeAfter(...scopes: Construct[]): void

Parameters

  • scopes Construct

Adds trigger dependencies.

Execute this trigger only after these construct scopes have been provisioned.


executeBefore(...scopes)

public executeBefore(...scopes: Construct[]): void

Parameters

  • scopes Construct

Adds this trigger as a dependency on other constructs.

This means that this trigger will get executed before the given construct(s).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.