To configure EventBridge rules for GuardDuty to send custom SNS notifications, complete the following steps:
-
Open the EventBridge console.
-
Under the Buses section, choose Rules.
-
Choose Create rule, and then complete the following steps to configure the rule:
Enter a name and description.
For Event bus, choose default.
For Rule type, choose Rule with an event pattern.
-
Choose Next.
-
Under Event pattern, complete the following steps:
For Event source, choose AWS services.
For AWS service, choose GuardDuty.
For Event type, choose GuardDuty Finding.
-
In the Event pattern preview section, choose Edit pattern.
-
In the JSON text box, enter the following code:
{
"source": ["aws.guardduty"],
"detail": {
"type": ["Backdoor:EC2/C&CActivity.B!DNS"]
}
}
Note: Replace Backdoor:EC2/C&CActivity.B!DNS with your finding type. To test the Backdoor:EC2/C&CActivity.B!DNS finding type, make a DNS request from an Amazon Elastic Compute Cloud (Amazon EC2) instance to the guarddutyc2activityb.com test domain. You can run the dig command for Linux or nslookup command for Windows. The finding generates within a few minutes.
-
Choose Next.
-
For Target types, choose AWS service.
-
For Select a target, choose SNS topic.
-
For Topic, select your topic.
-
(Optional) Configure an input transformer.
In the Target input transformer section, for Input path, enter the following JSON path in the text box:
{
"severity": "$.detail.severity",
"Finding_ID": "$.detail.id",
"instanceId": "$.detail.resource.instanceDetails.instanceId",
"port": "$.detail.service.action.networkConnectionAction.localPortDetails.port",
"eventFirstSeen": "$.detail.service.eventFirstSeen",
"eventLastSeen": "$.detail.service.eventLastSeen",
"count": "$.detail.service.count",
"Finding_Type": "$.detail.type",
"region": "$.region",
"Finding_description": "$.detail.description"
}
For Template, enter the following string template in the text box:
"You have a new GuardDuty alert. View finding in console - https://console.aws.amazon.com/guardduty/home?REGION=#/findings?search=id%3DFINDING_ID "
Note: In the template, keep the trailing space after FINDING_ID so that the closing quotation mark doesn't break the URL in the SNS notification. The Input path uses specific attributes from the GuardDuty finding. For more information about available filters, see Property filters in GuardDuty.
-
Choose Next.
-
(Optional) Add tags to your rule, and then choose Next.
-
Review the rule details, and then choose Create rule.