Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Testing an event pattern using the EventBridge Sandbox
Rules use event patterns to select events and send them to targets. Event patterns have
the same structure as the events they match. An event pattern either matches an event or it
doesn't.
Defining an event pattern is typically part of the larger process of creating a new rule or editing an existing one. Using
the Sandbox in EventBridge, however, you can quickly define an event pattern and use a sample event
to confirm the pattern matches the desired events, without having to create or edit a
rule. Once you've got your event pattern tested, EventBridge give you the option of creating a new rule using that event pattern directly from the sandbox.
For more information about event patterns, see Amazon EventBridge event patterns.
In EventBridge, it is possible to create rules that can lead to higher-than-expected charges
and throttling. For example, you can inadvertently create a rule that leads to an
infinite loop, where a rule is fired recursively without end. Suppose you created a rule
to detect that ACLs have changed on an Amazon S3 bucket, and trigger software to change them
to the desired state. If the rule is not written carefully, the subsequent change to the
ACLs fires the rule again, creating an infinite loop.
For guidance on how to write precise rules and event patterns to minimize such unexpected results,
see Best practices and Best practices.
To test an event pattern using the EventBridge sandbox
Open the Amazon EventBridge console at https://console.amazonaws.cn/events/.
-
In the navigation pane, choose Developer resources, then select Sandbox,
and on the Sandbox page choose the Event pattern tab.
-
For Event source, choose Amazon events or EventBridge
partner events.
-
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:
-
Amazon events – Select from events emitted
from supported Amazon Web 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 Amazon or partner event as the starting point for creating your own custom event.
Select Amazon 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 Amazon 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.
- Existing schema
-
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.
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.
-
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.
- Custom schema
-
To write a custom schema and convert it to an event pattern, do the
following:
-
In the Creation method section, for
Method, choose Use
schema.
-
In the Event pattern section, for
Schema type, choose Enter
schema.
-
Enter your schema into the text box. You must format the
schema as valid JSON text.
-
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.
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.
-
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.
- Event pattern
-
To write a custom event pattern in JSON format, do the
following:
-
In the Creation method section, for
Method, choose Custom pattern
(JSON editor).
-
For Event pattern, enter your custom
event pattern in JSON-formatted text.
-
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.
-
Event pattern form –
Opens the event pattern in Pattern Builder. If the
pattern can't be rendered in Pattern Builder as-is,
EventBridge warns you before it opens Pattern
Builder.
-
(Optional) To create a rule with this event pattern, and assign the rule to a specific event bus, choose Create rule with pattern.
EventBridge takes you to Step 1 of Create rule,
which you can use to create a rule and assign it to the event bus of your choice.
Note that Step 2 - Build event pattern contains the event
pattern information you've already specified, and which you can accept or update.
For more on how to create rules, see Creating rules that react to events in Amazon EventBridge.