class Trigger (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.Triggers.Trigger |
Java | software.amazon.awscdk.triggers.Trigger |
Python | aws_cdk.triggers.Trigger |
TypeScript (source) | @aws-cdk/triggers » Trigger |
Implements
IConstruct
, IConstruct
, IDependable
, ITrigger
Triggers an AWS Lambda function during deployment.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as lambda from '@aws-cdk/aws-lambda';
import * as triggers from '@aws-cdk/triggers';
import * as constructs from 'constructs';
declare const construct: constructs.Construct;
declare const function_: lambda.Function;
const trigger = new triggers.Trigger(this, 'MyTrigger', {
handler: function_,
// the properties below are optional
executeAfter: [construct],
executeBefore: [construct],
executeOnHandlerChange: false,
});
Initializer
new Trigger(scope: Construct, id: string, props: TriggerProps)
Parameters
- scope
Construct
- id
string
- props
Trigger
Props
Construct Props
Name | Type | Description |
---|---|---|
handler | Function | The AWS Lambda function of the handler to execute. |
execute | Construct [] | Adds trigger dependencies. Execute this trigger only after these construct scopes have been provisioned. |
execute | Construct [] | Adds this trigger as a dependency on other constructs. |
execute | boolean | Re-executes the trigger every time the handler changes. |
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.
Properties
Name | Type | Description |
---|---|---|
node | Construct | The construct tree node associated with this construct. |
node
Type:
Construct
The construct tree node associated with this construct.
Methods
Name | Description |
---|---|
execute | Adds trigger dependencies. |
execute | Adds this trigger as a dependency on other constructs. |
to | Returns a string representation of this construct. |
After(...scopes)
executepublic executeAfter(...scopes: Construct[]): void
Parameters
- scopes
Construct
Adds trigger dependencies.
Execute this trigger only after these construct scopes have been provisioned.
Before(...scopes)
executepublic 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).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.