interface OnEventOptions
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Events.OnEventOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsevents#OnEventOptions |
Java | software.amazon.awscdk.services.events.OnEventOptions |
Python | aws_cdk.aws_events.OnEventOptions |
TypeScript (source) | aws-cdk-lib » aws_events » OnEventOptions |
Implements
Event
Standard set of options for onXxx event handlers on construct.
Example
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
const repo = new ecr.Repository(this, 'Repo');
const lambdaHandler = new lambda.Function(this, 'LambdaFunction', {
runtime: lambda.Runtime.PYTHON_3_12,
code: lambda.Code.fromInline('# dummy func'),
handler: 'index.handler',
});
repo.onEvent('OnEventTargetLambda', {
target: new LambdaFunction(lambdaHandler),
});
Properties
| Name | Type | Description |
|---|---|---|
| cross | Construct | The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). |
| description? | string | A description of the rule's purpose. |
| event | Event | Additional restrictions for the event to route to the specified target. |
| rule | string | A name for the rule. |
| target? | IRule | The target to register for the event. |
crossStackScope?
Type:
Construct
(optional, default: none (the main scope will be used, even for cross-stack Events))
The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).
This helps dealing with cycles that often arise in these situations.
description?
Type:
string
(optional, default: No description)
A description of the rule's purpose.
eventPattern?
Type:
Event
(optional, default: No additional filtering based on an event pattern.)
Additional restrictions for the event to route to the specified target.
The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering.
ruleName?
Type:
string
(optional, default: AWS CloudFormation generates a unique physical ID.)
A name for the rule.
target?
Type:
IRule
(optional, default: No target is added to the rule. Use addTarget() to add a target.)
The target to register for the event.

.NET
Go
Java
Python
TypeScript (