以编程方式获取 ec2 定价? [英] get ec2 pricing programmatically?

查看:27
本文介绍了以编程方式获取 ec2 定价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以编程方式获得 AWS 定价(每种实例类型的每小时成本、S3 上每 GB/月的存储成本等)?

Is there a way to get AWS pricing programmatically (cost per hour of each instance type, cost per GB/month of storage on S3, and etc)?

另外,是否有成本监控工具?例如,是否有一种工具可以按小时报告您的 EC2 实例使用情况(而不是按月报告,亚马逊就是这样做的)?

Also, are there cost monitoring tools? For example, is there a tool that can report your EC2 instance usage on an hourly basis (versus a monthly basis, which is what Amazon does)?

提前致谢.

推荐答案

更新:

现在有 AWS 定价 API:https://aws.amazon.com/blogs/aws/new-aws-price-list-api/

There is now AWS pricing API: https://aws.amazon.com/blogs/aws/new-aws-price-list-api/

原始答案:

价格表以 AWS 定价页面使用的 JSONP 文件(您需要剥离函数调用)的形式提供.每个表(以及表的每个选项卡)都有单独的 JSON 文件.它可能不是 API,但绝对是计算机可消化的.以下是支持 EC2 定价页面的列表(截至 2014 年 12 月 17 日):

The price lists are available in form of JSONP files (you need to strip off function call) which are used by the AWS pricing pages. Each table (and each tab for table) has separate JSON file. It is not an API maybe, but definitely computer digestible. Here is a list that supports EC2 pricing page (as of 17 December 2014):

警告:端点会不时更改,并且旧 URL 通常仍然存在且具有旧值.最好检查当前状态,而不是依赖此线程中提供的链接.

WARNING: The endpoints change from time to time and often old URL is still there with old values. It is best to check what is the current status rather than relying on links provided in this thread.

因此,这是一个从任何 AWS 定价页面获取当前集合或 URL 的简短命令.基于 EC2 的示例.在 Linux 或 Cygwin 上运行它.实际上这个命令是用来创建上面的列表的.

So, here is a short command to get current set or URLs from any AWS pricing page. Example based on EC2. Run it on Linux or Cygwin. Actually this command was used to create the list above.

curl http://aws.amazon.com/ec2/pricing/ 2>/dev/null | grep 'model:' | sed -e "s/.*'(.*)'.*/http:\1/"

对于那些不喜欢命令行的人,你也可以在浏览器的网络控制台中查看(你用 F12 到达那里),用 JS 对象过滤:

For those who don't like command line, you can also check in a web browser network console (you get there with F12), filter with JS objects:

这篇关于以编程方式获取 ec2 定价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆