An easy way to generate Cloudwatch dashboards from within your cloudformation template.
This is a custom resource that will enable you to generate a Cloudwatch dashboard based on a list of resources you attach to the custom resource. Currently supported resource types are:
- ApiGateway
- Lambda
- S3
- aws cli
- aws sam
- docker
- aws vault (optional)
- python 3.9 (optional)
To deploy this custom resource to your account, first build the SAM package using the build command (see commands). Next deploy it to your account using the deploy command (see commands), you can change the deploy properties in de config file 'config/deploy.toml'.
You can use the resource using the following yaml example
DashboardFactoryCustomResource:
Type: Custom::DashboardFactory
Properties:
ServiceToken:
Fn::ImportValue:
!Sub "cr-aws-easy-dash-${AWS::Region}"
DashboardName: "test-dashboard"
Region: !Ref "AWS::Region"
Resources:
- MetricResourceType: ApiGateway
ResourceReference: ApiGatewayName
- MetricResourceType: Lambda
ResourceReference: !Ref HelloWorldFunction
When you make changes to this custom resource and want to test locally, you can use the local invoke commands (see commands).
You can add supported aws resources in the 'code/awsresources' folder, files need to be in json containing a dictionary with the resource type as a leading key.
For example: If you want to add support for let's say S3 you create a json file called s3.json and use S3 as leading key. When you want to use an S3 resource in the dashboard the value for 'MetricResourceType' will be 'S3'.
The json file needs to be provided in the aws defined json structure. See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html
aws cli: https://docs.aws.amazon.com/cli/index.html
aws vault: https://github.com/99designs/aws-vault
boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
docker: https://docs.docker.com/
sam local invoke --event local/events/cfnCreate.json DashboardFactory
sam local invoke --event local/events/cfnDelete.json DashboardFactory
sam build --parallel --use-container --build-image amazon/aws-sam-cli-build-image-python3.9
sam deploy --resolve-s3 --config-file 'config/deploy.toml'