EventBridgeRule - AWS Serverless Application Model

EventBridgeRule

The object describing an EventBridgeRule event source type, which sets your serverless function as the target of an Amazon EventBridge rule. For more information, see What Is Amazon EventBridge? in the Amazon EventBridge User Guide.

AWS SAM generates an AWS::Events::Rule resource when this event type is set. AWS SAM also creates an AWS::Lambda::Permission resource, which is needed so the EventBridgeRule can call Lambda.

Syntax

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

Properties

DeadLetterConfig

Configure the Amazon Simple Queue Service (Amazon SQS) queue where EventBridge sends events after a failed target invocation. Invocation can fail, for example, when sending an event to a Lambda function that doesn't exist, or when EventBridge has insufficient permissions to invoke the Lambda function. For more information, see Event retry policy and using dead-letter queues in the Amazon EventBridge User Guide.

Note

The AWS::Serverless::Function resource type has a similar data type, DeadLetterQueue, which handles failures that occur after successful invocation of the target Lambda function. Examples of these types of failures include Lambda throttling, or errors returned by the Lambda target function. For more information about the function DeadLetterQueue property, see Dead-letter queues in the AWS Lambda Developer Guide.

Type: DeadLetterConfig

Required: No

AWS CloudFormation compatibility: This property is similar to the DeadLetterConfig property of the AWS::Events::Rule Target data type. The AWS SAM version of this property includes additional subproperties, in case you want AWS SAM to create the dead-letter queue for you.

EventBusName

The event bus to associate with this rule. If you omit this property, AWS SAM uses the default event bus.

Type: String

Required: No

Default: Default event bus

AWS CloudFormation compatibility: This property is passed directly to the EventBusName property of an AWS::Events::Rule resource.

Input

Valid JSON text passed to the target. If you use this property, nothing from the event text itself is passed to the target.

Type: String

Required: No

AWS CloudFormation compatibility: This property is passed directly to the Input property of an AWS::Events::Rule Target resource.

InputPath

When you don't want to pass the entire matched event to the target, use the InputPath property to describe which part of the event to pass.

Type: String

Required: No

AWS CloudFormation compatibility: This property is passed directly to the InputPath property of an AWS::Events::Rule Target resource.

InputTransformer

Settings to enable you to provide custom input to a target based on certain event data. You can extract one or more key-value pairs from the event and then use that data to send customized input to the target. For more information, see Amazon EventBridge input transformation in the Amazon EventBridge User Guide.

Type: InputTransformer

Required: No

AWS CloudFormation compatibility: This property is passed directly to the InputTransformer property of an AWS::Events::Rule Target data type.

Pattern

Describes which events are routed to the specified target. For more information, see Amazon EventBridge events and EventBridge event patterns in the Amazon EventBridge User Guide.

Type: EventPattern

Required: Yes

AWS CloudFormation compatibility: This property is passed directly to the EventPattern property of an AWS::Events::Rule resource.

RetryPolicy

A RetryPolicy object that includes information about the retry policy settings. For more information, see Event retry policy and using dead-letter queues in the Amazon EventBridge User Guide.

Type: RetryPolicy

Required: No

AWS CloudFormation compatibility: This property is passed directly to the RetryPolicy property of the AWS::Events::Rule Target data type.

RuleName

The name of the rule.

Type: String

Required: No

AWS CloudFormation compatibility: This property is passed directly to the Name property of an AWS::Events::Rule resource.

State

The state of the rule.

Accepted values: DISABLED | ENABLED

Type: String

Required: No

AWS CloudFormation compatibility: This property is passed directly to the State property of an AWS::Events::Rule resource.

Target

The AWS resource that EventBridge invokes when a rule is triggered. You can use this property to specify the logical ID of the target. If this property is not specified, then AWS SAM generates the logical ID of the target.

Type: Target

Required: No

AWS CloudFormation compatibility: This property is similar to the Targets property of an AWS::Events::Rule resource. Amazon EC2 RebootInstances API call is an example of a target property. The AWS SAM version of this property only allows you to specify the logical ID of a single target.

Examples

EventBridgeRule

The following is an example of an EventBridgeRule event source type.

YAML

EBRule: Type: EventBridgeRule Properties: Input: '{"Key": "Value"}' Pattern: detail: state: - terminated RetryPolicy: MaximumRetryAttempts: 5 MaximumEventAgeInSeconds: 900 DeadLetterConfig: Type: SQS QueueLogicalId: EBRuleDLQ Target: Id: MyTarget