0
I am currently looking to build out an event driven EventBridge event module (as opposed to a scheduled one, for example) for usage in our IaaC portfolio. The example code below shows how the normal event JSON pattern would look. I can obviously add a normal single variable for the “detail-type” and the “source”, but can someone advise on a way to create some kind of single mapped variable that I could pass one or more parameters for the “detail” map?
event_pattern = <<PATTERN
{
"detail-type": ["Glue Job State Change"],
"source": ["aws.glue"],
"detail": {
"jobName": ["${var.env}_${var.department}_gluejob_${var.pipeline}_publish-small", "${var.env}_${var.department}_gluejob_${var.pipeline}_catalog", "${var.env}_${var.department}_gluejob_${var.pipeline}_publish-large", "${var.env}_${var.department}_gluejob_${var.pipeline}_notify"],
"state": ["FAILED"]
}
}
The need for this is that across a number of different services we may need any number of key and value parameters in “details” so some way to pass in a map which can have any number of key value pairs would be ideal. Now if this wasn’t json I could use a dynamic value in TF but I am unsure what to do here with it being an inline JSON pattern.
I should also mention before someone suggests it, that I have currently just done the work around of having the event pattern passed as variable and using data and a template json.tpl file that can pass the pattern for each resource in individually for each usage of the module, but would like to know if anyone can advise on the solution I was hoping was possible above?
Any advice would be greatly appreciated!