interface OnEventOptions
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Events.OnEventOptions |
![]() | software.amazon.awscdk.services.events.OnEventOptions |
![]() | aws_cdk.aws_events.OnEventOptions |
![]() | @aws-cdk/aws-events » OnEventOptions |
Standard set of options for onXxx
event handlers on construct.
Example
// Lambda function containing logic that evaluates compliance with the rule.
const evalComplianceFn = new lambda.Function(this, 'CustomFunction', {
code: lambda.AssetCode.fromInline('exports.handler = (event) => console.log(event);'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
});
// A custom rule that runs on configuration changes of EC2 instances
const customRule = new config.CustomRule(this, 'Custom', {
configurationChanges: true,
lambdaFunction: evalComplianceFn,
ruleScope: config.RuleScope.fromResource(config.ResourceType.EC2_INSTANCE),
});
// A rule to detect stack drifts
const driftRule = new config.CloudFormationStackDriftDetectionCheck(this, 'Drift');
// Topic to which compliance notification events will be published
const complianceTopic = new sns.Topic(this, 'ComplianceTopic');
// Send notification on compliance change events
driftRule.onComplianceChange('ComplianceChange', {
target: new targets.SnsTopic(complianceTopic),
});
Properties
Name | Type | Description |
---|---|---|
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. |
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.