AWS bills everything by the meter, so if you experience unexpected usage, you’re going to have to pay for it. AWS has alarms that can trigger if your bill gets too high.
Preventing Cloud Overflow
It’s not unusual to experience unexpectedly high resource usage, and you should plan for it in advance. This can happen for lots of reasons:
- Tons of extra traffic on a small site, usually from “going viral” and being linked somewhere. This can stress components of your infrastructure that you weren’t worried about paying for at your usual rate.
- “Cloud Overflow,” where a misconfiguration causes an infinite loop in the cloud, such as a Lambda function calling itself over and over.
- DDOS attempts on non-rate limited endpoints. While AWS will do their best to prevent these attacks, draining your wallet is still a viable attack vector.
Luckily, AWS still wants you as a regular customer, and it’s in both party’s best interests to keep costs down and prevent incidents like this.
To solve the issue, you can create “Billing Alarms” that will fire if your account uses too many resources. These are free for basic use, and quite simple to set up, so even if you don’t think it’s an issue, you should probably go ahead and create one just to be safe.
Enabling Billing Alarms
Billing Alarms are configured through CloudWatch, not the regular billing dashboard. However, you’ll need to enable Billing Alerts in your account to use it in the first place.
Head to the Billing Dashboard in the top right account menu, and click “Billing Preferences.” Enable billing alerts here.
Then, head over to the CloudWatch Management Console and select “Billing Alarms” on the sideboard.”
Click “Create Alarm.” If your screen doesn’t look like this, you may have to wait a few minutes for the billing alerts setting to enable across all of AWS.
You’ll be asked to select which metric you want to graph, as CloudWatch can set up alarms on any kind of metric. If you want this to apply to your whole account, select Billing > Total Estimated Charge.
You may have to wait a bit for billing data to appear in here, as it won’t come in until after you enable billing alerts. Once you have data to work from though, you can configure the alert in one of two ways—static, which fires when it goes over the threshold, or anomaly detection, which is a little smarter and can detect values outside a configured band.
You can then configure an action to take place. Create a new SNS topic on the next screen and configure it to send to whatever email address needs to see it.
Once saved, the alarm should be in place.
Using AWS Budgets
Another way of setting up alarms is using AWS’s new Budgets feature, which is more streamlined and simply allows you to set an amount you want to pay each month, and it will alarm if you’re about to go over. This is less accurate than a CloudWatch alarm, which can track billing and locate anomalies as they happen, but it’s easy to set up and works well for most applications.
Head over to the Billing Dashboard and create a new budget. You’ll see your last year of costs displayed by month, and you’ll be able to set an amount for the budget down below.
There are a few options here—“Fixed” allows you to set a single monthly amount, “Planned” allows you to set monthly amounts for the whole year, by month, and “Auto-Adjusting” will increase your budget automatically based on last month’s usage. Auto-adjusting can be helpful if your costs fluctuate a lot with traffic.
On the next screen, you can add an alert threshold. You can set this to a percentage of your budget (over or under). You’ll also want to make sure you select “Forecasted,” which will warn you about going over the budget in advance. You definitely don’t want to be halfway through the month only to learn you’ve already spent all your money.
Below, you can set up email recipients for this alert, or publish to SNS. You can also attach actions to this budget, such as turning off EC2 instances automatically if it gets too high.
- › What Do “FR” and “FRFR” Mean?
- › Logitech MX Mechanical Keyboard Review: Easy on the Eyes, Not the Fingertips
- › Logitech MX Master 3S Mouse Review: Muted Refinements
- › AMD’s Ryzen 7000 Series Are the First 5nm Desktop CPUs Ever
- › The Origins of Ctrl+C, Ctrl+V, Ctrl+X, and Ctrl+Z Explained
- › What’s New in Chrome 102, Arriving Today