Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS Billing Alert
# aws cloudformation deploy --region us-east-1 --stack-name billing-alerts --template-file billingalert.yaml
Description: "Billing alerts"
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
DevAlarmThreshold:
Description: Development account alarm threshold.
Type: Number
Default: 20
Resources:
DevSpendingAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmDescription: !Sub >
"Alarm if AWS development account spending is over $${DevAlarmThreshold}"
Namespace: AWS/Billing
MetricName: EstimatedCharges
Dimensions:
- Name: Currency
Value: USD
- Name: LinkedAccount
Value: YourNumericalAccountID
Statistic: Maximum
Period: '21600'
EvaluationPeriods: '1'
Threshold:
Ref: "DevAlarmThreshold"
ComparisonOperator: GreaterThanThreshold
AlarmActions:
- Ref: BillingAlertContact
InsufficientDataActions:
- Ref: BillingAlertContact
BillingAlertContact:
Type: AWS::SNS::Topic
Properties:
# Don't specify a TopicName as that will prevent resource updates that
# require replacement. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html#cfn-sns-topic-name
DisplayName: "BillingAlertNotification"
Subscription:
- Endpoint: "you@youremail.com"
Protocol: email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.