有没有一种方法来设置亚马逊 AWS 的收费限额?

我在 Amazon S3上开发应用。我如何保持我的 S3运行在一个设定的预算?假设我不希望意外流量超支我的 AWS 帐户。我还是不要了。

34385 次浏览

There is no way to set a budget for AWS.

But this feature is being requested very often, so probably one day it will be implemented.

https://forums.aws.amazon.com/thread.jspa?threadID=58127

As of December 2011, if you have an AWS premium account you can use CloudWatch to monitor your estimated charges and if they go over a certain limit you can trigger different actions (such as shutting down the machine)

http://blog.bitnami.org/2011/12/monitor-your-estimated-aws-charges-with.html

It seems there is still no solution provided by Amazon.

Take a look on Amazon Price-Watcher - Monitor your bill and auto-shut down your instances

So here is a basic script I've put together in Python which will sit and monitor the current price of your instance, and shut it down if it goes over a certain price-limit. (In the future, this can be changed to maybe throttling incoming bandwidth, or emailing the admin).

AWS has announced the general availability of the functionality to Monitor Estimated Charges Using Billing Alerts via Amazon CloudWatch as of May 10, 2012 (which according to Daniel Lopez' answer [+1] has been available to AWS premium accounts since end of 2011 already):

We regularly estimate the total monthly charge for each AWS service that you use. When you enable monitoring for your account, we begin storing the estimates as CloudWatch metrics, where they'll remain available for the usual 14 day period. [...]

As outlined in the introductory blog post, You can start by using the billing alerts to let you know when your AWS bill will be higher than expected, see Monitor Your Estimated Charges Using Amazon CloudWatch for more details regarding this functionality.

This is already pretty useful for many basic needs, however, using the CloudWatch APIs to retrieve the stored metrics yourself (see the GetMetricStatistics API and Getting Statistics for a Metric for usage samples) actually allows you to drive arbitrary workflows and business logic based upon this data.

Regarding the latter, the scope of this offering is stressed as well though:

It is important to note that these are estimates, not predictions. The estimate approximates the cost of your AWS usage to date within the current billing cycle and will increase as you continue to consume resources. [...] It does not take trends or potential changes in your AWS usage pattern into account. [emphasis mine]