This project implements a workflow to transform CloudWatch Alerts into Google Chat Cards v2 messages and sent them to a Google Chat Space.
It is called "SNS to Google Chat Space" beause technically any SNS message can be transformed and the intention is to add more templates in the future to apply transformations to different message types, but for now, only CloudWatch Alerts templates are supported.
NOTE: Currently there are no Lambda functions used. EventBridge Pipes orchestrates the workflow and the transformations are done via Input Transforms in Pipes instead of processing via a Lambda. This limits the transformations to simple field mappings from source message to destination fields but means there is basically $0 for this flow unless you have a lot of messages going through it (which would make for a very noisey Google CHat Space!).
This repository generates a CloudFormation template using the AWS CDK. You can choose to either:
The project supports both CDK context configuration properties or CloudFormation Parameters to define the configuration. Decide which one you want to use based upon (primarily) if you want to generate a template you can reuse and decide on the config when you deploy it, or if you want to script up the deployment in a CI/CD process. E.g. maybe you don't want to initialize an AWS Account with CDK deployment permissions so you generate and save the CloudFormation template to use whenever you need it.
This project supports defining configuration in a cdk.context.json
file or using CloudFormation Parameters as the configuration source. Each config property can be defined in either location and you can mix and match them. E.g. maybe you want to generate a tempalte that has the same Message title & icon but deploy it with different spaces. You can define the title & icon in the CDK Contet and leave the space definition as CloudFormation parameters (e.g. for when you want to deploy the template on dev vs prod and just change the channel the messages are sent to).
E.g. cdk.context.json
{
"GoogleChatConfig": {
"MessageTitle": "ProjectA",
"MessageIcon": "https://projecta.com/favicon.png",
"Space": {
"Label": "ProjectA_Alerts",
"Endpoint": "https://chat.googleapis.com/v1/spaces/AAAAeusufh7/messages?key=AIzaSyDkq&token=sdidfd
}
}
These values can also be set in a flat context structure in cdk.context.json
:
{
"GoogleChatMessageTitle": "ProjectA",
"GoogleChatMessageIcon": "https://projecta.com/favicon.png",
"GoogleChatSpaceLabel": "ProjectA_Alerts",
"GoogleChatSpaceEndpoint": "https://chat.googleapis.com/v1/spaces/AAAAeusufh7/messages?key=AIzaSyDkq&token=sdidfd
}
These values can be provided as parameters in the stack when you deploy (e.g. cdk deploy --parameters GoogleChatMessageTitle=ProjectA
).
These values can also be set as Context values on the cdk command line (e.g. cdk synth --context GoogleChatMessageTitle=ProjectA
).
Any configuration defined in the CDK context (cdk.context.json
or on the command line) supresses the CloudFormation Parameters for those config items (since you already defined the values, you don't need CloudFormation Parameters as well).
rawMessageDelivery
so that the SNS message wrapper is not included in the message.<$.body.FIELD>
to reference a FIELD
of the CloudWatch Alarm data. This is delivered to the Pipe as the Source message.<$.body.FIELD>
codes in the JSON to make copy-paste between the UI Kit Builder and the files in this project easy.< ... >
as a field definition. This is NOT documented in the EventBridge Pipes documentation and the EventBridge Pipes Web UX will show the correct output transform applied when you have HTML in the template but you will not be able to save the input transformer or deploy it. The main impact of this is that Google Chat relies on HTML for basic text formatting (vs Slack that lets you use markdown) so you cannot include a TextParagraph with formatting.