AWS estimated charges - get notified in a few steps!

AWS estimated charges - get notified in a few steps!

Whenever we deploy resources on AWS, we need to keep in mind that costs are something to monitor closely.

AWS offers a Free Tier, with the most used services for you to start exploring. And some of them are always free (within a given quota)!

If you are curious, here is the free tier offering vs quotas vs services.

AWS also offers a quick way of monitoring your usage and costs, which consists in enabling an alert whenever your forecasted costs reach a certain threshold using CloudWatch alarms and AWS SNS service (to send email notifications).

To add this feature, you will need to have access to your AWS Billing console and logged as a user with proper permissions or use the root account (not recommended).

Enabling notifications

In Billing Preferences > under Cost Management Preferences tick the box Receive Billing Alerts and save preferences. Also, tick Receive Free Tier Usage Alerts if you want to be notified about Free Tier usage.

Creating an alarm

Before starting, change your current region to us-east-1 (N. Virginia). This is where the Billing information is stored and represents worldwide charges.

In CloudWatch console, go to Alarms in the left pane and choose All Alarms.

  • Create alarm (top right).

  • Then Select metric.

  • In Browse, select Billing and then Total Estimated Charge.

  • Select the EstimatedCharges metric row and then Select metric.

  • For Statistics, select Maximum.

  • For Period, select 6 hours.

  • Next, for Threshold type, choose Static.

  • For Whenever EstimatedCharges is..., choose Greater.

  • For than... enter a threshold that will trigger this alarm. For this example, I used 2 USD as the value threshold.

    • For reference, I have mine set to 5 USD and it is more than enough to play around with my implementations.
  • In Additional configuration, leave Datapoints to alarm default 1 out of 1 and Treat missing data as missing.

  • Next.

  • In Notification section:

    • under Alarm state trigger, select In Alarm.

    • Send a notification to the following SNS topic, you can select an existing topic or create a new one (or use a topic ARN in a different account).

      • (In my case, I created a new topic).

      • Give it a descriptive name.

      • Add an email account to send emails to.

      • Create topic.

        • You will get an email asking to confirm the subscription. If you don't receive it in 5 minutes, check your Spam folder (mine got filtered by Gmail).

        • If for some reason you cannot confirm it via email, you can do it manually in the SNS console using the link generated after you click on Create topic.

  • Next.

  • Add a name for the alarm, and an optional description.

  • Preview the alarm and click Create alarm.

Then you will be able to see the alarm.

First in an Insufficient data status, then OK in a few minutes.

If you click on the alarm name you will be able to see its metrics over time. Keep in mind it is fetching data every 6 hours.

FIN! You now have a reliable alarm checking every 6 hours for your estimated charges.

Conclusion

Keep in mind the threshold you set for the alarm is a forecast value, based on current and past usage in your account. AWS will calculate this value as an estimation of what could be the final number on your current month's bill.

The actual charge could be way less. To check on the actual vs forecast, please visit your Billing console.

References


Thank you for stopping by! Do you know other ways to do this? Please let me know in the comments, I always like to learn how to do things differently.

Did you find this article valuable?

Support Mariano González by becoming a sponsor. Any amount is appreciated!