Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nivleshc/789341e7dfee5b25891537567f2ec63f to your computer and use it in GitHub Desktop.

Select an option

Save nivleshc/789341e7dfee5b25891537567f2ec63f to your computer and use it in GitHub Desktop.
This gist contains code from eventbridge.tf, which is part of the blog-amazon-macie-custom-eventbridge-events repository.
# EventBridge rule to capture the custom Macie job status change events
# published by the Lambda function
resource "aws_cloudwatch_event_rule" "macie_job_status" {
name = local.eventbridge.rule_name
description = local.eventbridge.rule_description
event_pattern = jsonencode({
source = [local.eventbridge.event_source]
detail-type = [local.eventbridge.detail_type]
})
}
# EventBridge target - send matching events to the SNS topic
resource "aws_cloudwatch_event_target" "sns" {
rule = aws_cloudwatch_event_rule.macie_job_status.name
target_id = "macie-job-status-sns-target"
arn = aws_sns_topic.macie_notifications.arn
input_transformer {
input_paths = {
jobId = "$.detail.jobId"
jobName = "$.detail.jobName"
eventType = "$.detail.eventType"
occurredAt = "$.detail.occurredAt"
}
input_template = "\"Amazon Macie Classification Job Status Change:\\n\\nJob Name: <jobName>\\nJob ID: <jobId>\\nEvent Type: <eventType>\\nOccurred At: <occurredAt>\""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment