I'm trying ot configure cloudwatch event rule that'll tigger sns topic. I have been facing problem to trigger sns topic from cloutwatch rule with event pattern created from terraform. Below is my terraform code:
resource "aws_cloudwatch_event_rule" "s3-event" {
name = "s3-event"
description = "Capture each AWS s3 event"
event_pattern = <<EOF
{
"source": ["aws.s3"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventSource": ["s3.amazonaws.com"],
"eventName": ["CreateBucket"]
}
}
EOF
}
After apply the checked the event pattern on aws ui it look like :
Event pattern
{
"detail": {
"eventName": ["CreateBucket"],
"eventSource": ["s3.amazonaws.com"]
},
"detail-type": ["AWS API Call via CloudTrail"],
"source": ["aws.s3"]
}
IT gave invocation failed error on creation of s3 bucket. then I resaved as from aws console:
{
"source": ["aws.s3"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventSource": ["s3.amazonaws.com"],
"eventName": ["CreateBucket"]
}
}
then it passed.
Can someone suggest how I disable the terraform to rearrange event pattern.