Now Supports CloudFormation Conditions
CloudFormation Macro that will append a set of CloudWatch alarms for supported resources.
Lambda, and Dynamo DB
Service | Alarm | Description |
---|---|---|
Lambda | Errors | The number of invocations that failed due to errors in the function (response code 4XX) |
Dynamo DB | ConsumedReadCapacityUnits | When 80% of read capacity units have been reached (Works only on provisioned throughput) |
Dynamo DB | ConsumedWriteCapacityUnits | When 80% of write capacity units have been reached (Works only on provisioned throughput) |
Clone the git repo Use the AWS CLI to set the appropriate profile/API keys. Open a terminal, and from the root of the repository directory, type the following, replacing $BUCKET and $STACKNAME with your own values.
aws cloudformation package --template-file ServerlessAlarmsMacro.yaml --s3-bucket $BUCKET --output-template-file packaged-template.yaml
aws cloudformation deploy --template-file packaged-template.yaml --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND --stack-name $STACKNAME
To use the macro, add the following line to the top of your templates:
Transform: ServerlessAlarmMacro
If you are deploying a serverless template please ensure you list this macro after the serverless transform
Transform:
- AWS::Serverless-2016-10-31
- ServerlessAlarmMacro
Since you are more than likely going to be publishing alarms to an SNS topic, the following parameter is required in your template.
AlarmsSNSArn:
Type: String
Description: Name for alarms sns topic
Default: 'arn:aws:sns:<region>:<account>:<topic name>'
You can change this by passing it into your cloudformation changeset creation if you want to have different topics for different stages.
If you want to disable the creation of the alarms, a use case would be if you did not want any alarms on your test or beta stages. Do disable, add the following param on your template:
AlarmsDisabled:
AllowedValues:
- true
- false
Default: false,
Type: String
Description: Disable creation of alarms in the ServerlessAlarmMacro
I will progressively start adding more types of resources and allow a configureable template
My initial template was based off of the AWS supplied macro AlarmsMacro and some additional knowledge from learned from SAR-cloudwatch-alarms-macro