You can use the Input transformer in EventBridge to customize text from an event before you send it to the target of a rule.
To do this, you define JSON paths from the event and assign their outputs to different variables. Then you can use those variables in the input template. The characters < and > can't be escaped. For more information, see Amazon EventBridge input transformation
NoteIf you specify a variable to match a JSON path that doesn't exist in the event, that variable isn't created and doesn't appear in the output.
In this tutorial, you create a rule that matches an event with detail-type: "customerCreated"
. The input transformer maps the type
variable to the $.detail-type JSON path from the event. Then EventBridge puts the variable into the input template "This event was <type>." The result is the following Amazon SNS message.
"This event was of customerCreated type."
Step 1: Create an Amazon SNS topic
Create a topic to receive the events from EventBridge.
To create a topicOpen the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home.
In the navigation pane, choose Topics.
Choose Create topic.
For Type, choose Standard.
Enter eventbridge-IT-test
as the name of the topic.
Choose Create topic.
Create a subscription to get emails with the transformed information.
To create a subscriptionOpen the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home.
In the navigation pane, choose Subscriptions.
Choose Create subscription.
For Topic ARN, choose the topic you created in step 1. For this tutorial, choose eventbridge-IT-test.
For Protocol, choose Email.
For Endpoint, enter your email address.
Choose Create subscription.
Confirm the subscription by choosing Confirm subscription in the email you receive from AWS notifications.
Create a rule to use the input transformer to customize the instance state information that goes to a target.
To create a ruleOpen the Amazon EventBridge console at https://console.aws.amazon.com/events/.
In the navigation pane, choose Rules.
Choose Create rule.
Enter a name and description for the rule. For example, name the rule ARTestRule
For Event bus, choose the event bus that you want to associate with this rule. If you want this rule to match events that come from your account, select default. 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.
For Event source, choose Other.
For Event pattern, enter the following:
{
"detail-type": [
"customerCreated"
]
}
Choose Next.
For Target types, choose AWS service.
For Select a target, choose SNS topic from the drop-down list.
For Topic, select the Amazon SNS topic that you created in step 1. For this tutorial, choose eventbridge-IT-test.
For Additional settings, do the following:
For Configure target input, choose Input transformer from the drop-down list.
Choose Configure input transformer
for Sample events, enter the following:
{
"detail-type": "customerCreated"
}
For Target input transformer do the following:
For Input Path, enter the following:
{"detail-type":"$.detail-type"}
For Input Template, enter the following:
"This event was of <detail-type> type."
Choose Confirm..
Choose Next.
Choose Next.
Review the details of the rule and choose Create rule.
Now that you've set up the SNS topic and the rule, we'll send test events to make sure the rule is working correctly.
To send test events (console)Open the Amazon EventBridge console at https://console.aws.amazon.com/events/.
In the navigation pane, choose Event buses.
In the Default event bus tile, choose Actions, Send events.
Enter an event source. For example, TestEvent
.
For Detail type, enter customerCreated
.
For Event detail, enter {}
.
Choose Send.
If you get an email from AWS notifications that matches the expected output, you've successfully completed the tutorial.
Step 6: Clean up your resourcesYou can now delete the resources that you created for this tutorial, unless you want to retain them. By deleting AWS resources that you are no longer using, you prevent unnecessary charges to your AWS account.
To delete the SNS topicOpen the Topics page of the SNS console.
Select the topic that you created.
Choose Delete.
Enter delete me
.
Choose Delete.
Open the Subscriptions page of the SNS console.
Select the subscription that you created.
Choose Delete.
Choose Delete.
Open the Rules page of the EventBridge console.
Select the rule(s) that you created.
Choose Delete.
Choose Delete.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4