Skip to content

Commit 4e26d08

Browse files
authored
Merge pull request #320 from NHSDigital/bugfix/eja-eli-304-amend-eventbridge-template
eli-304 changing eventbridge format to single line
2 parents 2829de6 + 3f5d0ed commit 4e26d08

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

infrastructure/stacks/api-layer/eventbridge.tf

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,7 @@ resource "aws_cloudwatch_event_target" "firehose_target" {
7373
reason = "$.detail.state.reason"
7474
}
7575

76-
# Use a heredoc string so EventBridge placeholders like <time> are not JSON-escaped
77-
# (jsonencode would turn < and > into \u003c/\u003e, preventing substitution).
78-
input_template = <<TEMPLATE
79-
{
80-
"time": "<time>",
81-
"source": "elid-${var.environment}:cloudwatch:alarm",
82-
"sourcetype": "aws:cloudwatch:alarm",
83-
"event": {
84-
"alarm_name": "<alarm_name>",
85-
"new_state": "<new_state>",
86-
"old_state": "<old_state>",
87-
"reason": "<reason>",
88-
"region": "<region>"
89-
}
90-
}
91-
TEMPLATE
76+
# Eventbridge + Firehose splits events if we don't put on single line
77+
input_template = "\"{ \\\"time\\\": \\\"<time>\\\", \\\"source\\\": \\\"elid-${var.environment}:cloudwatch:alarm\\\", \\\"sourcetype\\\": \\\"aws:cloudwatch:alarm\\\", \\\"event\\\": { \\\"alarm_name\\\": \\\"<alarm_name>\\\", \\\"new_state\\\": \\\"<new_state>\\\", \\\"old_state\\\": \\\"<old_state>\\\", \\\"reason\\\": \\\"<reason>\\\", \\\"region\\\": \\\"<region>\\\" } }\""
9278
}
9379
}

0 commit comments

Comments
 (0)