Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created November 8, 2016 05:27
Show Gist options
  • Select an option

  • Save Kalimaha/467f9f0c4e8645d9a3943c89d69ae06e to your computer and use it in GitHub Desktop.

Select an option

Save Kalimaha/467f9f0c4e8645d9a3943c89d69ae06e to your computer and use it in GitHub Desktop.
Monitoring Stack
Description: Monitoring Stack
Parameters:
TopicName:
Description: Name for the SNS topic used for the monitoring
Type: String
AlarmName:
Description: Name for the CloudWatch alarm
Type: String
AlarmEndpoint:
Description: Alarm integration URL
Type: String
AlarmProtocol:
Description: Alarm protocol
Type: String
Resources:
SNSTopic:
Type: "AWS::SNS::Topic"
Properties:
TopicName: !Ref TopicName
DisplayName: !Ref TopicName
SNSTopicPolicy:
Type: "AWS::SNS::TopicPolicy"
Properties:
PolicyDocument:
Id: SNSTopicPolicyID
Version: "2012-10-17"
Statement:
Sid: ''
Effect: Allow
Principal:
AWS: "*"
Action: sns:Publish
Resource: "*"
Topics:
- !Ref SNSTopic
CloudWatchAlarm:
Type: "AWS::CloudWatch::Alarm"
Properties:
AlarmName: !Ref AlarmName
AlarmDescription: !Ref AlarmName
AlarmActions:
- !Ref AlarmTopic
MetricName: NumberOfMessagesPublished
Namespace: "AWS/SNS"
Statistic: Sum
Period: 3600
EvaluationPeriods: 1
Threshold: 10
ComparisonOperator: LessThanThreshold
Dimensions:
- Name: TopicName
Value: !GetAtt SNSTopic.TopicName
AlarmTopic:
Type: "AWS::SNS::Topic"
Properties:
DisplayName: Notification topic for monitoring
Subscription:
- Protocol: !Ref AlarmProtocol
Endpoint: !Ref AlarmEndpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment