# OnEventOptions

Standard set of options for `onXxx` event handlers on construct.

Extends: OnEventOptions
Extends: EventCommonOptions

- Source: [`aws-events/lib/on-event-options.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-events/lib/on-event-options.ts#L50)
- Type last changed: v2.38.0 · 17 Aug 2022

## Example

```ts
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

- `crossStackScope`: [Construct](/cdk/api/v2/docs/constructs.Construct.html) — The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).

  **Default:** none (the main scope will be used, even for cross-stack Events)

  This helps dealing with cycles that often arise in these situations.

- `description`: string — A description of the rule's purpose.

  **Default:** No description

- `eventPattern`: [EventPattern](/cdk/api/v2/docs/aws-cdk-lib.aws_events.EventPattern.html) — Additional restrictions for the event to route to the specified target.

  **Default:** No additional filtering based on an event pattern.

  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`: string — A name for the rule.

  **Default:** AWS CloudFormation generates a unique physical ID.

- `target`: [IRuleTarget](/cdk/api/v2/docs/aws-cdk-lib.aws_events.IRuleTarget.html) — The target to register for the event.

  **Default:** No target is added to the rule. Use `addTarget()` to add a target.
