30

I'm spinning up a free tier instance and I don't want to accidentally exceed the limit. How do I do that?

Alexander Suraphel
  • 525
  • 1
  • 5
  • 13

1 Answers1

35

You can't set a limit on AWS spending. AWS doesn't have a limit function - it's not in their interest, even though they do quite well at putting the customers first and trying to help the customer save money.

Billing Alarms

You can set up multiple billing alarms, which will warn you when the estimated monthly bill reaches the thresholds you set. You set these up in CloudWatch, in the N. Virginia region. In CloudWatch, click billing, create alarm, select "total estimated charge", then set up the screen something like this.

CloudWatch billing alert

Budgets

Budgets are another way to manage costs. They're a lot more flexible than billing alarms, a lot more granular. You can set them up by service, or by metric.

Cost Explorer

The cost explorer is an interesting too. It won't alert you, but you can see what you spend your money on.

You can use it to see charts that show what you're spending money on. For example this chart shows this account spends most of the money on EC2, but some on glacier, S3, and other bits and pieces. The chart underneath tells you exactly what the cost is.

AWS Cost Explorer

Free Tier

The free tier gives you enough credit to run a single EC2 t2.micro instance for a year, with sufficient disk, snapshot storage, etc, to be useful. You get a heap of other things free, like Lambda, RDS, EBS, EFS, a very generous allocation (unlike Azure - which gives you a month trial). Many people will end up paying a little bit for things like snapshots, bandwidth, etc, but that seems fair given how much you do get.

What I Do

I find it best to create multiple billing alarms, say at $5, $10, $20, $50, and $100. That should cover you. If you get multiple notifications at one time get in there quickly and work out what's going on. I also use budgets

CloudTrail

CloudTrail is a good service to monitor API calls in your account, so you know who creates what resources, and when. It can be tricky to work out exactly what it's saying because it's all JSON, but if something goes wrong at least you have all the information to work out what happened. I assume there are commercial services that make these logs easier to understand.

Per Second Billing

As @avinashbot points out below, as of 2nd October 2017, all billing for most Linux instances is by the second instead of by the hour. That makes trying things out significantly cheaper.

Tim
  • 31,888
  • 7
  • 52
  • 78
  • 9
    I don't mind paying a few bucks. What I am worried is that I don't inadvertently cost myself insane amount of cost. Thanks for the answer! – Alexander Suraphel Sep 18 '17 at 10:34
  • 9
    You won't as long as you pay attention to what your doing and don't go spinning up 100s of VMs for days at a time. I've used some of the higher tier ones for an hour or two at a time to test things out, stopped and deleted them as soon as I'm done with them and they cost me exactly what I'd expect (2 hours usage for instance). Just remember that you'll still be billed for stopped VMs (as the resources are still allocated) so deleting them when your done is necessary to keep costs to a minimum. – RobbG Sep 18 '17 at 13:25
  • 3
    @RobbG Yeah, the last part (and similar gotchas) are the issue. AWS is really powerful but is kinda complicated, and it can be hard for new users to be sure what they're using. – sudo Sep 18 '17 at 18:14
  • 2
    As a side note, spinning up larger instances to test things out is a lot cheaper now with [per-second billing](https://aws.amazon.com/blogs/aws/new-per-second-billing-for-ec2-instances-and-ebs-volumes/) (with a minimum of 1 minute) – avinashbot Sep 19 '17 at 07:49
  • 1
    @RobbG You won't necessarily be charged when your instances are stopped, just the EBS price (if you're using it instead of Instance Store) and the Elastic IP price (if you've allocated one even after stopping your instance). – avinashbot Sep 19 '17 at 07:54