Hi Folks,
I’m trying to set up a cloudwatch event target for AWS Health events. The sample AWS health event is the following
{
"version": "0",
"id": "7bf73129-1428-4cd3-a780-95db273d1602",
"detail-type": "AWS Health Event",
"source": "aws.health",
"account": "123456789012",
"time": "2016-06-05T06:27:57Z",
"region": "region",
"resources": [],
"detail": {
"eventArn": "arn:aws:health:region::event/id",
"service": "service",
"eventTypeCode": "AWS_service_code",
"eventTypeCategory": "category",
"startTime": "Sun, 05 Jun 2016 05:01:10 GMT",
"endTime": "Sun, 05 Jun 2016 05:30:57 GMT",
"eventDescription": [{
"language": "lang-code",
"latestDescription": "description"
}]
...
}
}
and the Terraform code is
resource "aws_cloudwatch_event_target" "aws_health" {
rule = aws_cloudwatch_event_rule.aws_health.name
target_id = "send-to-sns"
arn = aws_sns_topic.alerts.arn
input_transformer {
input_paths = {
type = "$.detail-type"
account = "$.account"
description = "$.detail.0.eventDescription.latestDescription"
}
input_template = "\"You have a <type> notification in account ID <account>. The description of the notification is as follows: <description>.\""
}
}
My issue is that I’m not sure how to reference the input path for the event description as it is an array not a hash.
My guess is that it would be
description = "$.detail.0.eventDescription.latestDescription"
but I’m not sure as I can’t find any documentation related to this which explains the syntax when the JSON is an array.
Any ideas?
Thanks in advance for any pointers.
Trevor