Let CloudFormation create resource groups and CloudWatch dashboards
October 22, 2020
A while ago I looked into this article and its sample code as I liked the idea of getting auto-generated CloudWatch dashboards for monitoring stack resources.
I ported the small sample application to the Serverless Framework and now, with CloudFormation support for Resource Groups, all it takes to create a resource group containing all supported resources of the deployed stack is … a bit of CloudFormation :-)
resources:
Resources:
ResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name: ${self:service.name}-${self:provider.stage}
All resources added to the CloudFormation stack in the future will automatically be included in the created resource group.
For creating groups of existing resouces, based on tags or complete stacks, the ResourceQuery
property can be used. Consult the referenced article.
Monitoring
Creating a resource group brings the added benefit of auto-generated CloudWatch dashboards for monitoring the application. The CloudWatch home page features a dropdown that defaults to “All resources”. Select a resource group to see the generated dashboard.
A complete runnable example can be found here.