Skip to content

Commit 2829de6

Browse files
authored
Merge pull request #316 from NHSDigital/bugfix/eja-eli-304-amend-eventbridge-template
eli-304 - bugfix - amending eventbridge template
2 parents d308c2d + c1ccc9b commit 2829de6

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

infrastructure/stacks/api-layer/eventbridge.tf

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

76-
input_template = jsonencode({
77-
time = "<time>"
78-
source = "elid-${var.environment}:cloudwatch:alarm"
79-
sourcetype = "aws:cloudwatch:alarm"
80-
event = {
81-
alarm_name = "<alarm_name>"
82-
new_state = "<new_state>"
83-
old_state = "<old_state>"
84-
reason = "<reason>"
85-
region = "<region>"
86-
}
87-
})
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
8892
}
8993
}

0 commit comments

Comments
 (0)