Setup a billing alarm for your AWS account with cloudformation
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
This comment has been minimized.
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