To take action on events received by Amazon EventBridge, you can create rules. When an event matches the event pattern defined in your rule, EventBridge sends the event to the specified target and triggers the action defined in the rule.
The following video explores creating different kinds of rules, and how to test them:
The following steps walk you through how to create a rule that EventBridge uses to match events as they are sent to the specified event bus.
Define the rule
First, enter a name and description for your rule to identify it. You must also define the event bus where your rule looks for events to match to an event pattern.
To define the rule detail
Open the Amazon EventBridge console at https://console.aws.amazon.com/events/
. -
In the navigation pane, choose Rules.
-
Choose Create rule.
-
Enter a Name and, optionally, a Description for the rule.
A rule can't have the same name as another rule in the same AWS Region and on the same event bus.
-
For Event bus, choose the event bus to associate with this rule. If you want this rule to match events that come from your account, select AWS default event bus. When an AWS service in your account emits an event, it always goes to your account’s default event bus.
-
For Rule type, choose Rule with an event pattern.
-
Choose Next.
Build the event pattern
Next, build the event pattern. To do this, specify the event source, choose the basis for the event pattern, and define the attributes and values to match on. You can also generate the event pattern in JSON and test it against a sample event.
To build the event pattern
-
For Event source, choose AWS events or EventBridge partner events.
-
(Optional) In the Sample events section, choose a Sample event type against which you want to test your event pattern.
The following sample event types are available:
-
AWS events – Select from events emitted from supported AWS services.
-
EventBridge partner events – Select from events emitted from third-party services that support EventBridge, such as Salesforce.
-
Enter my own – Enter your own event in JSON text.
You can also use an AWS or partner event as the starting point for creating your own custom event.
Select AWS events or EventBridge partner events.
Use the Sample events dropdown to select the event you want to use as a starting point for your custom event.
EventBridge displays the sample event.
Select Copy.
Select Enter my own for Event type.
Delete the sample event structure in the JSON editing pane, and paste the AWS or partner event in its place.
Edit the event JSON to create your own sample event.
-
-
Choose a Creation method. You can create an event pattern from an EventBridge schema or template, or you can create a custom event pattern.
To use an existing EventBridge schema to create the event pattern, do the following:
-
In the Creation method section, for Method, select Use schema.
-
In the Event pattern section, for Schema type, select Select schema from Schema registry.
-
For Schema registry, choose the dropdown box and enter the name of a schema registry, such as
aws.events
. You can also select an option from the dropdown list that appears. -
For Schema, choose the dropdown box and enter the name of the schema to use. For example,
aws.s3@ObjectDeleted
. You can also select an option from the dropdown list that appears. -
In the Models section, choose the Edit button next to any attribute to open its properties. Set the Relationship and Value fields as needed, then choose Set to save the attribute.
Note
For information about an attribute's definition, choose the Info icon next to the attribute's name. For a reference on how to set attribute properties in your event, open the Note section of the attribute properties dialog box.
To delete an attribute's properties, choose the Edit button for that attribute, then choose Clear.
-
Choose Generate event pattern in JSON to generate and validate your event pattern as JSON text.
-
(Optional) To test the sample event against your test pattern, choose Test pattern.
EventBridge displays a message box stating whether your sample event matches the event pattern.
You can also choose any of the following options:
-
Copy – Copy the event pattern to your device's clipboard.
-
Prettify – Makes the JSON text easier to read by adding line breaks, tabs, and spaces.
-
-
Choose Next.
Select targets
Choose one or more targets to receive events that match the specified pattern. Targets can include an EventBridge event bus, EventBridge API destinations, including SaaS partners such as Salesforce, or another AWS service.
To select targets
-
For Target type, choose one of the following target types:
Select EventBridge event bus.
Choose the event bus to use as the target.
-
To use an event bus in the same AWS Region as this rule:
Select Event bus in the same account and Region.
For Event bus for target, choose the dropdown box and enter the name of the event bus. You can also select the event bus from the dropdown list.
For more information, see Sending events between event buses in the same account and Region in Amazon EventBridge.
-
To use an event bus in a different AWS Region or account as this rule:
Select Event bus in a different account or Region.
For Event bus as target, enter the ARN of the event bus you want to use.
For more information, see:
-
-
For many target types, EventBridge needs permissions to send events to the target. In these cases, EventBridge can create the IAM role needed for your rule to run.
For Execution role, do one of the following:
-
To create a new execution role for this rule:
Select Create a new role for this specific resource.
Either enter a name for this execution role, or use the name generated by EventBridge.
-
To use an existing execution role for this rule:
Select Use existing role.
Enter or select the name of the execution role to use from the dropdown list.
-
-
(Optional) For Additional settings, specify any of the optional settings available for your target type:
(Optional) For Dead-letter queue, choose whether to use a standard Amazon SQS queue as a dead-letter queue. EventBridge sends events that match this rule to the dead-letter queue if they are not successfully delivered to the target. Do one of the following:
-
Choose None to not use a dead-letter queue.
-
Choose Select an Amazon SQS queue in the current AWS account to use as the dead-letter queue and then select the queue to use from the drop-down list.
-
Choose Select an Amazon SQS queue in an other AWS account as a dead-letter queue and then enter the ARN of the queue to use. You must attach a resource-based policy to the queue that grants EventBridge permission to send messages to it.
For more information, see Granting permissions to the dead-letter queue.
-
-
(Optional) Choose Add another target to add another target for this rule.
-
Choose Next.
Configure tags and review rule
Finally, enter any desired tags for the rule, then review and create the rule.
To configure tags, and review and create the rule
-
(Optional) Enter one or more tags for the rule. For more information, see Tagging resources in Amazon EventBridge.
-
Choose Next.
-
Review the details for the new rule. To make changes to any section, choose the Edit button next to that section.
When satisfied with the rule details, choose Create rule.