Last active
November 8, 2020 13:04
-
-
Save Nxtra/6629097f7ab7dd99bf01bb7b4f06e60e to your computer and use it in GitHub Desktop.
Setup a billing alarm for your AWS account with cloudformation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: Billing Alerts for your AWS Account | |
Parameters: | |
Email: | |
Type: String | |
Default: youremail@somerandomdomain.com | |
Description: The email address to receive alerts per email | |
Phone: | |
Type: String | |
Default: "+3212312828345" | |
Description: The mobile phone number to receive SMS message alerts | |
Mappings: | |
EstimatedCharges: | |
AlarmRange: | |
"Threshold": 10 # Triggers an alarm if charges go above $10 | |
Resources: | |
BillingAlert: | |
Type: AWS::CloudWatch::Alarm | |
Properties: | |
AlarmActions: | |
- !Ref BillingAlertTopic | |
AlarmDescription: | |
!Join [ | |
"", | |
[Alert for $, !FindInMap [EstimatedCharges, AlarmRange, Threshold]], | |
] | |
ComparisonOperator: GreaterThanThreshold | |
Dimensions: | |
- Name: Currency | |
Value: USD | |
EvaluationPeriods: 1 | |
MetricName: EstimatedCharges | |
Namespace: AWS/Billing | |
Period: 21600 | |
TreatMissingData: ignore | |
Statistic: Maximum | |
Threshold: !FindInMap [EstimatedCharges, AlarmRange, One] | |
BillingAlertTopic: | |
Type: AWS::SNS::Topic | |
AlarmSubscriberEmail: | |
Type: AWS::SNS::Subscription | |
Properties: | |
Endpoint: !Ref Email | |
Protocol: email | |
TopicArn: !Ref BillingAlertTopic | |
AlarmSubscriberSMS: | |
Type: AWS::SNS::Subscription | |
Properties: | |
Endpoint: !Ref Phone | |
Protocol: sms | |
TopicArn: !Ref BillingAlertTopic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Deploy using the following command:
Based on: https://github.com/tarasowski/aws-billing-alarm-cloudformation-template. Extended by: https://github.com/Nxtra/aws-billing-alarms