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.
YAML
DeadLetterConfig:DeadLetterConfigEventBusName:StringInput:StringInputPath:StringInputTransformer:InputTransformerPattern:EventPatternRetryPolicy:RetryPolicyRuleName:StringState:StringTarget:Target
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 functionDeadLetterQueueproperty, see Dead-letter queues in the AWS Lambda Developer Guide.Type: DeadLetterConfig
Required: No
CloudFormation compatibility: This property is similar to the
DeadLetterConfigproperty of theAWS::Events::RuleTargetdata 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
CloudFormation compatibility: This property is passed directly to the
EventBusNameproperty of anAWS::Events::Ruleresource. -
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
CloudFormation compatibility: This property is passed directly to the
Inputproperty of anAWS::Events::Rule Targetresource. -
InputPath -
When you don't want to pass the entire matched event to the target, use the
InputPathproperty to describe which part of the event to pass.Type: String
Required: No
CloudFormation compatibility: This property is passed directly to the
InputPathproperty of anAWS::Events::Rule Targetresource. -
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
CloudFormation compatibility: This property is passed directly to the
InputTransformerproperty of anAWS::Events::RuleTargetdata 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
CloudFormation compatibility: This property is passed directly to the
EventPatternproperty of anAWS::Events::Ruleresource. -
RetryPolicy -
A
RetryPolicyobject 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
CloudFormation compatibility: This property is passed directly to the
RetryPolicyproperty of theAWS::Events::RuleTargetdata type. -
RuleName -
The name of the rule.
Type: String
Required: No
CloudFormation compatibility: This property is passed directly to the
Nameproperty of anAWS::Events::Ruleresource. -
State -
The state of the rule.
Accepted values:
DISABLED|ENABLED|ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTSType: String
Required: No
CloudFormation compatibility: This property is passed directly to the
Stateproperty of anAWS::Events::Ruleresource. -
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
CloudFormation compatibility: This property is similar to the
Targetsproperty of anAWS::Events::Ruleresource.Amazon EC2 RebootInstances API callis 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