AWS: Setting Up a Billing Alarm

21 Nov, 2020
  • Share
Post image

When using AWS you may incur unexpected charges due to various reasons. For example, you can make a mistake while calculating the cost of a particular service, or a mistake when setting up the service, or when your app gets unexpectedly large amount of traffic, etc.

So, if you use AWS for a real project or just for experimenting with the services, it's a great idea to set up a billing alarm to get notified when your AWS charges exceed a certain threshold. This allows you to examine the costs of the services you use and take them under control before the charges grow too large, especially if the exceeding charges are due to a mistake you made while setting up the services.

Enabling the Billing Alerts Option

To create a billing alarm you have to enable the billing alerts option. With billing alerts enabled you'll be able to monitor your AWS usage charges and recurring fees. Basically, this enables billing data collection in your account, you'll be able to see your AWS charges statistics on the Billing dashboard in CloudWatch. Important: if you enable the billing alerts option, you cannot disable it.

To enable the billing alerts option and to be able to create billing alarms you have to login using your root account's credentials or as an IAM user with permission to view billing information.

To enable the billing alerts option:

  1. Open Billing & Cost Management Dashboard

  2. In the menu, click Billing Preferences

    billing-preferences-menu-item

  3. Check Receive Billing Alerts (once you enable this option, you won't be able to disable it)

    receive-billing-alerts-option

  4. Click Save Preferences

Creating Billing Alarms

  1. Open the CloudWatch console and switch to the US East (N. Virginia) (us-east-1) region. At the moment (November, 2020) CloudWatch displays the billing data only in this region.

  2. In the menu, click Alarms

  3. Click Create alarm

  4. Click Select metric

  5. In the All metrics tab click Billing and choose Total Estimated Charge

  6. Check the row with the metric name EstimatedCharges

    estimatedcharges-metric

  7. Click Select metric

  8. Under Conditions, select Static for the Threshold type and Greater for the Whenever EstimatedCharges is... option

  9. For than... enter the monthly amount (e.g., 10). When your monthly charges become greater than this amount, the alarm will go off (go into ALARM state)

    alarm-conditions

  10. Click Next

  11. Under Notification, for Alarm state trigger select In alarm

  12. Select the SNS (Simple Notification Service) topic that is gonna get the notification. You can either use an existing topic or create a new one. If you're setting up a billing alarm for the first time you most probably will need to create a new topic. So, select Create new topic. You'll need to enter the topic name and the email addresses that will receive the notification.

    alarm-notification-settings

  13. If you created a new topic, SNS should have sent the Subscription Confirmation email to the email addresses that you've added to the topic. You need to click the Confirm subscription link in that email to confirm that you allow SNS to send you notification emails regarding that topic. The owners of other email addresses you specified should do the same. If you don't confirm the subscription, you won't receive the Alarm notifications.

  14. Click Next

  15. Enter the alarm's name (e.g., "Billing Greater Than 10 USD") and description.

    alarm-name-and-description

  16. Click Next

  17. Review the alarm options and if everything is correct, click Create alarm

It takes some time for the alarm to get initialized. If the current monthly charges are greater than the alarm's threshold, the alarm should go off once it is initialized.

new-alarm-triggered

Please note that the billing metrics are updated every six hours. CloudWatch will be able to check your spending only every six hours and this means that you most probably will not get the notification immediately at the point when your spending reaches the alarm's threshold.

Also, I want to mention that you can create multiple billing alarms.

AWS Budgets

Another way to monitor your AWS account's spending and to set up notifications for when the charges go over a given threshold, is to use the AWS Budgets feature (Billing & Cost Management Dashboard -> Budgets). I'm planning to talk about creating a cost budget in another blog post.

aws-budgets

Useful Resources

Creating a Billing Alarm to Monitor Your Estimated AWS Charges

Pssst...

You know React already? Wanna learn how to use TypeScript with it?

Get this detailed online course and learn TypeScript and how to use it in React applications.

Start Now on Udemy
Discount Code: AUGUST2023
Course thumb image