forked from marcy-terui/gs-aws-pricing-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebs.gs
76 lines (70 loc) · 2.11 KB
/
ebs.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function get_ebs_price(region, type_name, sub_price) {
if(!sub_price) sub_price = false
var data = eval(getPriceData("http://a0.awsstatic.com/pricing/1/ebs/pricing-ebs.min.js"));
var regions = data['config']['regions'];
for (var i = 0; i < regions.length; i++) {
if(regions[i]['region'] == getOdRegion(region)) {
var types = regions[i]['types'];
for (var j = 0; j < types.length; j++) {
if(types[j]['name'] == type_name) {
if(!sub_price) { return types[j]['values'][0]['prices']['USD']; }
else { return types[j]['values'][1]['prices']['USD']; }
}
}
}
}
}
/**
* Get price of hourly payment (per GB) on EBS General Purpose (SSD) volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_GP2_STORAGE(region) {
return get_ebs_price(region, "Amazon EBS General Purpose (SSD) volumes");
}
/**
* Get price of hourly payment (per GB) on EBS Magnetic volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_MAGNETIC_STORAGE(region) {
return get_ebs_price(region, "Amazon EBS Magnetic volumes");
}
/**
* Get price of hourly payment (per GB) on EBS Provisioned IOPS (SSD) volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_PIOPS_STORAGE(region) {
return get_ebs_price(region, "Amazon EBS Provisioned IOPS (SSD) volumes");
}
/**
* Get price of hourly payment (per IOPS) on EBS Provisioned IOPS (SSD) volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_PIOPS_PROV(region) {
return get_ebs_price(region, "Amazon EBS Provisioned IOPS (SSD) volumes", true);
}
/**
* Get price of hourly payment (per 1M IO requests) on EBS Provisioned IOPS (SSD) volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_MAGNETIC_IO(region) {
return get_ebs_price(region, "Amazon EBS Magnetic volumes", true);
}
/**
* Get price of hourly payment (per 1M IO requests) on EBS Provisioned IOPS (SSD) volumes.
*
* @param {region} Region(optional)
* @customfunction
*/
function EBS_SNAPSHOT_STORAGE(region) {
return get_ebs_price(region, "ebsSnapsToS3");
}