Skip to content

AWS Cloudformation macro for creating serverless related cloudwatch alarms

License

Notifications You must be signed in to change notification settings

gakinson/ServerlessAlarmsMacro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudwatch-serverless-alarm-macro

Now Supports CloudFormation Conditions

CloudFormation Macro that will append a set of CloudWatch alarms for supported resources.

Included alarms

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)

Installation

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 

Usage

To use the macro, add the following line to the top of your templates:

Transform: ServerlessAlarmMacro

Macro Order for Serverless Templates

If you are deploying a serverless template please ensure you list this macro after the serverless transform

Transform: 
  - AWS::Serverless-2016-10-31
  - ServerlessAlarmMacro

Required Params

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.

Additional Params

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

Future Work

I will progressively start adding more types of resources and allow a configureable template

Honourable Mentions

My initial template was based off of the AWS supplied macro AlarmsMacro and some additional knowledge from learned from SAR-cloudwatch-alarms-macro

About

AWS Cloudformation macro for creating serverless related cloudwatch alarms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages