I am trying to use Cloud Custodian
webhooks to create tagged events in Datadog
using the Datadog API.
The following code nearly works, except account_id
is not created as a tag in Datadog
. If I capture the body sent, it contains "01234"
(i.e. a string.)
- type: webhook
url: https://api.datadoghq.eu/api/v1/events
method: POST
headers:
DD-API-KEY: '`{{ dd_api_key }}`'
body: |-
{
"title": `nutkin news`,
"text": `squirrel found in account`,
"tags": [resource.Name, policy.name, account_id]
}
If I remove the jmespath
queries in tags and just send string literals e.g.
`01234`
, it will not be appear in Datadog
as a tag, but if I send
`aws_account_id:01234`
it will appear as a tag.
Ideally, for all the tags, I would like a mix of a string and the result of the jmespath
query, as it would be more useable for users of Datadog
(e.g. something like what is included below.)
"tags": [`resource_name:`resource.Name, `policy_name:`policy.name, `account_id:`account_id]
I've spent days on this. I've read all the docs on custodian
, json
and jmespath
and just can't find the right syntax of brackets, quotes and backticks. Maybe it is not even possible to mix string literals and jmespath
queries.
Just to reiterate the question, how do I combine string literals with jmespath
queries to build up a web hook body in custodian web hooks
?