Skip to content

Instantly share code, notes, and snippets.

@kylegordon
Created March 29, 2019 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylegordon/3dc90b693ccc1af5aa1973a34fb7169f to your computer and use it in GitHub Desktop.
Save kylegordon/3dc90b693ccc1af5aa1973a34fb7169f to your computer and use it in GitHub Desktop.
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