sumomo 0.8.3 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +169 -0
- data/Gemfile +2 -0
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/data/sumomo/api_modules/node_modules/.bin/uuid +1 -1
- data/data/sumomo/api_modules/real_script.js +37 -1
- data/data/sumomo/api_modules/test_script.js +212 -175
- data/data/sumomo/custom_resources/AMILookup.js +146 -58
- data/data/sumomo/custom_resources/Echo.js +25 -0
- data/data/sumomo/custom_resources/SelectSpot.js +142 -54
- data/data/sumomo/custom_resources/TempS3Bucket.js +213 -0
- data/data/sumomo/custom_resources/USEastCertificate.js +44 -31
- data/data/sumomo/custom_resources/USEastCertificateWaiter.js +60 -0
- data/exe/sumomo +50 -41
- data/lib/sumomo.rb +236 -233
- data/lib/sumomo/api.rb +148 -151
- data/lib/sumomo/cdn.rb +119 -113
- data/lib/sumomo/dns.rb +20 -20
- data/lib/sumomo/ec2.rb +490 -491
- data/lib/sumomo/ecs.rb +256 -262
- data/lib/sumomo/irregular.rb +9 -0
- data/lib/sumomo/momo_extensions/resource.rb +8 -7
- data/lib/sumomo/momo_extensions/stack.rb +4 -3
- data/lib/sumomo/network.rb +109 -106
- data/lib/sumomo/stack.rb +191 -189
- data/lib/sumomo/version.rb +3 -1
- data/sumomo.gemspec +23 -22
- metadata +27 -22
@@ -1,64 +1,152 @@
|
|
1
1
|
|
2
2
|
var typeToArch = {
|
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
|
-
"g2.
|
38
|
-
|
39
|
-
"
|
40
|
-
"
|
41
|
-
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
|
46
|
-
"i2.
|
47
|
-
"i2.
|
48
|
-
"
|
49
|
-
|
50
|
-
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
|
55
|
-
|
56
|
-
|
3
|
+
"c1.medium": "PV64",
|
4
|
+
"c1.xlarge": "PV64",
|
5
|
+
"c3.2xlarge": "HVM64",
|
6
|
+
"c3.4xlarge": "HVM64",
|
7
|
+
"c3.8xlarge": "HVM64",
|
8
|
+
"c3.large": "HVM64",
|
9
|
+
"c3.xlarge": "HVM64",
|
10
|
+
"c4.2xlarge": "HVM64",
|
11
|
+
"c4.4xlarge": "HVM64",
|
12
|
+
"c4.8xlarge": "HVM64",
|
13
|
+
"c4.large": "HVM64",
|
14
|
+
"c4.xlarge": "HVM64",
|
15
|
+
"c5.18xlarge": "HVM64",
|
16
|
+
"c5.2xlarge": "HVM64",
|
17
|
+
"c5.4xlarge": "HVM64",
|
18
|
+
"c5.9xlarge": "HVM64",
|
19
|
+
"c5.large": "HVM64",
|
20
|
+
"c5.xlarge": "HVM64",
|
21
|
+
"c5d.18xlarge": "HVM64",
|
22
|
+
"c5d.2xlarge": "HVM64",
|
23
|
+
"c5d.4xlarge": "HVM64",
|
24
|
+
"c5d.9xlarge": "HVM64",
|
25
|
+
"c5d.large": "HVM64",
|
26
|
+
"c5d.xlarge": "HVM64",
|
27
|
+
"cc2.8xlarge": "HVM64",
|
28
|
+
"cr1.8xlarge": "HVM64",
|
29
|
+
"d2.2xlarge": "HVM64",
|
30
|
+
"d2.4xlarge": "HVM64",
|
31
|
+
"d2.8xlarge": "HVM64",
|
32
|
+
"d2.xlarge": "HVM64",
|
33
|
+
"f1.16xlarge": "HVM64",
|
34
|
+
"f1.2xlarge": "HVM64",
|
35
|
+
"f1.4xlarge": "HVM64",
|
36
|
+
"g2.2xlarge": "HVMG2",
|
37
|
+
"g2.8xlarge": "HVMG2",
|
38
|
+
"g3.16xlarge": "HVMG2",
|
39
|
+
"g3.4xlarge": "HVMG2",
|
40
|
+
"g3.8xlarge": "HVMG2",
|
41
|
+
"h1.16xlarge": "HVM64",
|
42
|
+
"h1.2xlarge": "HVM64",
|
43
|
+
"h1.4xlarge": "HVM64",
|
44
|
+
"h1.8xlarge": "HVM64",
|
45
|
+
"hs1.8xlarge": "HVM64",
|
46
|
+
"i2.2xlarge": "HVM64",
|
47
|
+
"i2.4xlarge": "HVM64",
|
48
|
+
"i2.8xlarge": "HVM64",
|
49
|
+
"i2.xlarge": "HVM64",
|
50
|
+
"i3.16xlarge": "HVM64",
|
51
|
+
"i3.2xlarge": "HVM64",
|
52
|
+
"i3.4xlarge": "HVM64",
|
53
|
+
"i3.8xlarge": "HVM64",
|
54
|
+
"i3.large": "HVM64",
|
55
|
+
"i3.metal": "HVM64",
|
56
|
+
"i3.xlarge": "HVM64",
|
57
|
+
"m1.large": "PV64",
|
58
|
+
"m1.medium": "PV64",
|
59
|
+
"m1.small": "PV64",
|
60
|
+
"m1.xlarge": "PV64",
|
61
|
+
"m2.2xlarge": "PV64",
|
62
|
+
"m2.4xlarge": "PV64",
|
63
|
+
"m2.xlarge": "PV64",
|
64
|
+
"m3.2xlarge": "HVM64",
|
65
|
+
"m3.large": "HVM64",
|
66
|
+
"m3.medium": "HVM64",
|
67
|
+
"m3.xlarge": "HVM64",
|
68
|
+
"m4.10xlarge": "HVM64",
|
69
|
+
"m4.16xlarge": "HVM64",
|
70
|
+
"m4.2xlarge": "HVM64",
|
71
|
+
"m4.4xlarge": "HVM64",
|
72
|
+
"m4.large": "HVM64",
|
73
|
+
"m4.xlarge": "HVM64",
|
74
|
+
"m5.12xlarge": "HVM64",
|
75
|
+
"m5.24xlarge": "HVM64",
|
76
|
+
"m5.2xlarge": "HVM64",
|
77
|
+
"m5.4xlarge": "HVM64",
|
78
|
+
"m5.large": "HVM64",
|
79
|
+
"m5.xlarge": "HVM64",
|
80
|
+
"m5d.12xlarge": "HVM64",
|
81
|
+
"m5d.24xlarge": "HVM64",
|
82
|
+
"m5d.2xlarge": "HVM64",
|
83
|
+
"m5d.4xlarge": "HVM64",
|
84
|
+
"m5d.large": "HVM64",
|
85
|
+
"m5d.xlarge": "HVM64",
|
86
|
+
"p2.16xlarge": "HVM64",
|
87
|
+
"p2.8xlarge": "HVM64",
|
88
|
+
"p2.xlarge": "HVM64",
|
89
|
+
"p3.16xlarge": "HVM64",
|
90
|
+
"p3.2xlarge": "HVM64",
|
91
|
+
"p3.8xlarge": "HVM64",
|
92
|
+
"r3.2xlarge": "HVM64",
|
93
|
+
"r3.4xlarge": "HVM64",
|
94
|
+
"r3.8xlarge": "HVM64",
|
95
|
+
"r3.large": "HVM64",
|
96
|
+
"r3.xlarge": "HVM64",
|
97
|
+
"r4.16xlarge": "HVM64",
|
98
|
+
"r4.2xlarge": "HVM64",
|
99
|
+
"r4.4xlarge": "HVM64",
|
100
|
+
"r4.8xlarge": "HVM64",
|
101
|
+
"r4.large": "HVM64",
|
102
|
+
"r4.xlarge": "HVM64",
|
103
|
+
"r5.12xlarge": "HVM64",
|
104
|
+
"r5.24xlarge": "HVM64",
|
105
|
+
"r5.2xlarge": "HVM64",
|
106
|
+
"r5.4xlarge": "HVM64",
|
107
|
+
"r5.large": "HVM64",
|
108
|
+
"r5.xlarge": "HVM64",
|
109
|
+
"r5d.12xlarge": "HVM64",
|
110
|
+
"r5d.24xlarge": "HVM64",
|
111
|
+
"r5d.2xlarge": "HVM64",
|
112
|
+
"r5d.4xlarge": "HVM64",
|
113
|
+
"r5d.large": "HVM64",
|
114
|
+
"r5d.xlarge": "HVM64",
|
115
|
+
"t1.micro": "PV64",
|
116
|
+
"t2.2xlarge": "HVM64",
|
117
|
+
"t2.large": "HVM64",
|
118
|
+
"t2.medium": "HVM64",
|
119
|
+
"t2.micro": "HVM64",
|
120
|
+
"t2.nano": "HVM64",
|
121
|
+
"t2.small": "HVM64",
|
122
|
+
"t2.xlarge": "HVM64",
|
123
|
+
"t3.2xlarge": "HVM64",
|
124
|
+
"t3.large": "HVM64",
|
125
|
+
"t3.medium": "HVM64",
|
126
|
+
"t3.micro": "HVM64",
|
127
|
+
"t3.nano": "HVM64",
|
128
|
+
"t3.small": "HVM64",
|
129
|
+
"t3.xlarge": "HVM64",
|
130
|
+
"x1.16xlarge": "HVM64",
|
131
|
+
"x1.32xlarge": "HVM64",
|
132
|
+
"x1e.16xlarge": "HVM64",
|
133
|
+
"x1e.2xlarge": "HVM64",
|
134
|
+
"x1e.32xlarge": "HVM64",
|
135
|
+
"x1e.4xlarge": "HVM64",
|
136
|
+
"x1e.8xlarge": "HVM64",
|
137
|
+
"x1e.xlarge": "HVM64",
|
138
|
+
"z1d.12xlarge": "HVM64",
|
139
|
+
"z1d.2xlarge": "HVM64",
|
140
|
+
"z1d.3xlarge": "HVM64",
|
141
|
+
"z1d.6xlarge": "HVM64",
|
142
|
+
"z1d.large": "HVM64",
|
143
|
+
"z1d.xlarge": "HVM64",
|
144
|
+
}
|
57
145
|
|
58
146
|
var archToAMINamePattern = {
|
59
|
-
"PV64": "amzn-ami-pv
|
60
|
-
"HVM64": "
|
61
|
-
"HVMG2": "
|
147
|
+
"PV64": "amzn-ami-pv*x86_64-ebs",
|
148
|
+
"HVM64": "amzn2-ami-hvm-2.0.*x86_64-gp2",
|
149
|
+
"HVMG2": "amzn2-ami-graphics-hvm-2.0.*x86_64-ebs*"
|
62
150
|
};
|
63
151
|
|
64
152
|
var ec2 = new aws.EC2({region: request.ResourceProperties.Region});
|
@@ -86,7 +174,7 @@ ec2.describeImages(describeImagesParams, function(err, describeImagesResult)
|
|
86
174
|
var response = {}
|
87
175
|
var id = "NONE";
|
88
176
|
var images = describeImagesResult.Images;
|
89
|
-
// Sort images by name in
|
177
|
+
// Sort images by name in descending order. The names contain the AMI version, formatted as YYYY.MM.Ver.
|
90
178
|
images.sort(function(x, y) { return y.Name.localeCompare(x.Name); });
|
91
179
|
for (var j = 0; j < images.length; j++)
|
92
180
|
{
|
@@ -0,0 +1,25 @@
|
|
1
|
+
function success()
|
2
|
+
{
|
3
|
+
Cloudformation.send(
|
4
|
+
request,
|
5
|
+
context,
|
6
|
+
Cloudformation.SUCCESS,
|
7
|
+
{},
|
8
|
+
"Success",
|
9
|
+
request.ResourceProperties.Value);
|
10
|
+
}
|
11
|
+
|
12
|
+
if (request.RequestType == "Create")
|
13
|
+
{
|
14
|
+
success()
|
15
|
+
}
|
16
|
+
|
17
|
+
if (request.RequestType == "Update")
|
18
|
+
{
|
19
|
+
success()
|
20
|
+
}
|
21
|
+
|
22
|
+
if (request.RequestType == "Delete")
|
23
|
+
{
|
24
|
+
success()
|
25
|
+
}
|
@@ -15,60 +15,148 @@ var want_to_pay = request.ResourceProperties.TargetPrice;
|
|
15
15
|
var exclude = exclude_string.split(",")
|
16
16
|
|
17
17
|
var typeToCapability = {
|
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
|
-
}
|
18
|
+
"c1.medium": { cpu: 2048, memory: 1740, gen: 1, ecu: 5120 },
|
19
|
+
"c1.xlarge": { cpu: 8192, memory: 7168, gen: 1, ecu: 20480 },
|
20
|
+
"c3.2xlarge": { cpu: 8192, memory: 15360, gen: 3, ecu: 28672 },
|
21
|
+
"c3.4xlarge": { cpu: 16384, memory: 30720, gen: 3, ecu: 56320 },
|
22
|
+
"c3.8xlarge": { cpu: 32768, memory: 61440, gen: 3, ecu: 110592 },
|
23
|
+
"c3.large": { cpu: 2048, memory: 3840, gen: 3, ecu: 7168 },
|
24
|
+
"c3.xlarge": { cpu: 4096, memory: 7680, gen: 3, ecu: 14336 },
|
25
|
+
"c4.2xlarge": { cpu: 8192, memory: 15360, gen: 4, ecu: 36864 },
|
26
|
+
"c4.4xlarge": { cpu: 16384, memory: 30720, gen: 4, ecu: 73728 },
|
27
|
+
"c4.8xlarge": { cpu: 36864, memory: 61440, gen: 4, ecu: 165888 },
|
28
|
+
"c4.large": { cpu: 2048, memory: 3840, gen: 4, ecu: 9216 },
|
29
|
+
"c4.xlarge": { cpu: 4096, memory: 7680, gen: 4, ecu: 18432 },
|
30
|
+
"c5.18xlarge": { cpu: 73728, memory: 147456, gen: 5, ecu: 368640 },
|
31
|
+
"c5.2xlarge": { cpu: 8192, memory: 16384, gen: 5, ecu: 40960 },
|
32
|
+
"c5.4xlarge": { cpu: 16384, memory: 32768, gen: 5, ecu: 81920 },
|
33
|
+
"c5.9xlarge": { cpu: 36864, memory: 73728, gen: 5, ecu: 184320 },
|
34
|
+
"c5.large": { cpu: 2048, memory: 4096, gen: 5, ecu: 10240 },
|
35
|
+
"c5.xlarge": { cpu: 4096, memory: 8192, gen: 5, ecu: 20480 },
|
36
|
+
"c5d.18xlarge": { cpu: 73728, memory: 147456, gen: 5, ecu: 368640 },
|
37
|
+
"c5d.2xlarge": { cpu: 8192, memory: 16384, gen: 5, ecu: 40960 },
|
38
|
+
"c5d.4xlarge": { cpu: 16384, memory: 32768, gen: 5, ecu: 81920 },
|
39
|
+
"c5d.9xlarge": { cpu: 36864, memory: 73728, gen: 5, ecu: 184320 },
|
40
|
+
"c5d.large": { cpu: 2048, memory: 4096, gen: 5, ecu: 10240 },
|
41
|
+
"c5d.xlarge": { cpu: 4096, memory: 8192, gen: 5, ecu: 20480 },
|
42
|
+
"cc2.8xlarge": { cpu: 32768, memory: 62464, gen: 1, ecu: 90112 },
|
43
|
+
"cr1.8xlarge": { cpu: 32768, memory: 249856, gen: 1, ecu: 90112 },
|
44
|
+
"d2.2xlarge": { cpu: 8192, memory: 62464, gen: 2, ecu: 24576 },
|
45
|
+
"d2.4xlarge": { cpu: 16384, memory: 124928, gen: 2, ecu: 49152 },
|
46
|
+
"d2.8xlarge": { cpu: 36864, memory: 249856, gen: 2, ecu: 110592 },
|
47
|
+
"d2.xlarge": { cpu: 4096, memory: 31232, gen: 2, ecu: 12288 },
|
48
|
+
"f1.16xlarge": { cpu: 65536, memory: 999424, gen: 1, ecu: 163840 },
|
49
|
+
"f1.2xlarge": { cpu: 8192, memory: 124928, gen: 1, ecu: 20480 },
|
50
|
+
"f1.4xlarge": { cpu: 16384, memory: 249856, gen: 1, ecu: 40960 },
|
51
|
+
"g2.2xlarge": { cpu: 8192, memory: 15360, gen: 2, ecu: 26624 },
|
52
|
+
"g2.8xlarge": { cpu: 32768, memory: 61440, gen: 2, ecu: 106496 },
|
53
|
+
"g3.16xlarge": { cpu: 65536, memory: 499712, gen: 3, ecu: 229376 },
|
54
|
+
"g3.4xlarge": { cpu: 16384, memory: 124928, gen: 3, ecu: 57344 },
|
55
|
+
"g3.8xlarge": { cpu: 32768, memory: 249856, gen: 3, ecu: 114688 },
|
56
|
+
"h1.16xlarge": { cpu: 65536, memory: 262144, gen: 1, ecu: 163840 },
|
57
|
+
"h1.2xlarge": { cpu: 8192, memory: 32768, gen: 1, ecu: 20480 },
|
58
|
+
"h1.4xlarge": { cpu: 16384, memory: 65536, gen: 1, ecu: 40960 },
|
59
|
+
"h1.8xlarge": { cpu: 32768, memory: 131072, gen: 1, ecu: 81920 },
|
60
|
+
"hs1.8xlarge": { cpu: 16384, memory: 119808, gen: 1, ecu: 35840 },
|
61
|
+
"i2.2xlarge": { cpu: 8192, memory: 62464, gen: 2, ecu: 27648 },
|
62
|
+
"i2.4xlarge": { cpu: 16384, memory: 124928, gen: 2, ecu: 54272 },
|
63
|
+
"i2.8xlarge": { cpu: 32768, memory: 249856, gen: 2, ecu: 106496 },
|
64
|
+
"i2.xlarge": { cpu: 4096, memory: 31232, gen: 2, ecu: 14336 },
|
65
|
+
"i3.16xlarge": { cpu: 65536, memory: 499712, gen: 3, ecu: 294912 },
|
66
|
+
"i3.2xlarge": { cpu: 8192, memory: 62464, gen: 3, ecu: 36864 },
|
67
|
+
"i3.4xlarge": { cpu: 16384, memory: 124928, gen: 3, ecu: 73728 },
|
68
|
+
"i3.8xlarge": { cpu: 32768, memory: 249856, gen: 3, ecu: 147456 },
|
69
|
+
"i3.large": { cpu: 2048, memory: 15616, gen: 3, ecu: 9216 },
|
70
|
+
"i3.metal": { cpu: 73728, memory: 524288, gen: 3, ecu: 331776 },
|
71
|
+
"i3.xlarge": { cpu: 4096, memory: 31232, gen: 3, ecu: 18432 },
|
72
|
+
"m1.large": { cpu: 2048, memory: 7680, gen: 1, ecu: 4096 },
|
73
|
+
"m1.medium": { cpu: 1024, memory: 3840, gen: 1, ecu: 2048 },
|
74
|
+
"m1.small": { cpu: 1024, memory: 1740, gen: 1, ecu: 1024 },
|
75
|
+
"m1.xlarge": { cpu: 4096, memory: 15360, gen: 1, ecu: 8192 },
|
76
|
+
"m2.2xlarge": { cpu: 4096, memory: 35020, gen: 2, ecu: 13312 },
|
77
|
+
"m2.4xlarge": { cpu: 8192, memory: 70040, gen: 2, ecu: 26624 },
|
78
|
+
"m2.xlarge": { cpu: 2048, memory: 17510, gen: 2, ecu: 6656 },
|
79
|
+
"m3.2xlarge": { cpu: 8192, memory: 30720, gen: 3, ecu: 26624 },
|
80
|
+
"m3.large": { cpu: 2048, memory: 7680, gen: 3, ecu: 6656 },
|
81
|
+
"m3.medium": { cpu: 1024, memory: 3840, gen: 3, ecu: 3072 },
|
82
|
+
"m3.xlarge": { cpu: 4096, memory: 15360, gen: 3, ecu: 13312 },
|
83
|
+
"m4.10xlarge": { cpu: 40960, memory: 163840, gen: 4, ecu: 163840 },
|
84
|
+
"m4.16xlarge": { cpu: 65536, memory: 262144, gen: 4, ecu: 262144 },
|
85
|
+
"m4.2xlarge": { cpu: 8192, memory: 32768, gen: 4, ecu: 32768 },
|
86
|
+
"m4.4xlarge": { cpu: 16384, memory: 65536, gen: 4, ecu: 65536 },
|
87
|
+
"m4.large": { cpu: 2048, memory: 8192, gen: 4, ecu: 8192 },
|
88
|
+
"m4.xlarge": { cpu: 4096, memory: 16384, gen: 4, ecu: 16384 },
|
89
|
+
"m5.12xlarge": { cpu: 49152, memory: 196608, gen: 5, ecu: 221184 },
|
90
|
+
"m5.24xlarge": { cpu: 98304, memory: 393216, gen: 5, ecu: 442368 },
|
91
|
+
"m5.2xlarge": { cpu: 8192, memory: 32768, gen: 5, ecu: 36864 },
|
92
|
+
"m5.4xlarge": { cpu: 16384, memory: 65536, gen: 5, ecu: 73728 },
|
93
|
+
"m5.large": { cpu: 2048, memory: 8192, gen: 5, ecu: 9216 },
|
94
|
+
"m5.xlarge": { cpu: 4096, memory: 16384, gen: 5, ecu: 18432 },
|
95
|
+
"m5d.12xlarge": { cpu: 49152, memory: 196608, gen: 5, ecu: 221184 },
|
96
|
+
"m5d.24xlarge": { cpu: 98304, memory: 393216, gen: 5, ecu: 442368 },
|
97
|
+
"m5d.2xlarge": { cpu: 8192, memory: 32768, gen: 5, ecu: 36864 },
|
98
|
+
"m5d.4xlarge": { cpu: 16384, memory: 65536, gen: 5, ecu: 73728 },
|
99
|
+
"m5d.large": { cpu: 2048, memory: 8192, gen: 5, ecu: 9216 },
|
100
|
+
"m5d.xlarge": { cpu: 4096, memory: 16384, gen: 5, ecu: 18432 },
|
101
|
+
"p2.16xlarge": { cpu: 65536, memory: 749568, gen: 2, ecu: 196608 },
|
102
|
+
"p2.8xlarge": { cpu: 32768, memory: 499712, gen: 2, ecu: 98304 },
|
103
|
+
"p2.xlarge": { cpu: 4096, memory: 62464, gen: 2, ecu: 12288 },
|
104
|
+
"p3.16xlarge": { cpu: 65536, memory: 499712, gen: 3, ecu: 229376 },
|
105
|
+
"p3.2xlarge": { cpu: 8192, memory: 62464, gen: 3, ecu: 28672 },
|
106
|
+
"p3.8xlarge": { cpu: 32768, memory: 249856, gen: 3, ecu: 114688 },
|
107
|
+
"r3.2xlarge": { cpu: 8192, memory: 62464, gen: 3, ecu: 26624 },
|
108
|
+
"r3.4xlarge": { cpu: 16384, memory: 124928, gen: 3, ecu: 53248 },
|
109
|
+
"r3.8xlarge": { cpu: 32768, memory: 249856, gen: 3, ecu: 106496 },
|
110
|
+
"r3.large": { cpu: 2048, memory: 15616, gen: 3, ecu: 6656 },
|
111
|
+
"r3.xlarge": { cpu: 4096, memory: 31232, gen: 3, ecu: 13312 },
|
112
|
+
"r4.16xlarge": { cpu: 65536, memory: 499712, gen: 4, ecu: 262144 },
|
113
|
+
"r4.2xlarge": { cpu: 8192, memory: 62464, gen: 4, ecu: 32768 },
|
114
|
+
"r4.4xlarge": { cpu: 16384, memory: 124928, gen: 4, ecu: 65536 },
|
115
|
+
"r4.8xlarge": { cpu: 32768, memory: 249856, gen: 4, ecu: 131072 },
|
116
|
+
"r4.large": { cpu: 2048, memory: 15616, gen: 4, ecu: 8192 },
|
117
|
+
"r4.xlarge": { cpu: 4096, memory: 31232, gen: 4, ecu: 16384 },
|
118
|
+
"r5.12xlarge": { cpu: 49152, memory: 393216, gen: 5, ecu: 221184 },
|
119
|
+
"r5.24xlarge": { cpu: 98304, memory: 786432, gen: 5, ecu: 442368 },
|
120
|
+
"r5.2xlarge": { cpu: 8192, memory: 65536, gen: 5, ecu: 36864 },
|
121
|
+
"r5.4xlarge": { cpu: 16384, memory: 131072, gen: 5, ecu: 73728 },
|
122
|
+
"r5.large": { cpu: 2048, memory: 16384, gen: 5, ecu: 9216 },
|
123
|
+
"r5.xlarge": { cpu: 4096, memory: 32768, gen: 5, ecu: 18432 },
|
124
|
+
"r5d.12xlarge": { cpu: 49152, memory: 393216, gen: 5, ecu: 221184 },
|
125
|
+
"r5d.24xlarge": { cpu: 98304, memory: 786432, gen: 5, ecu: 442368 },
|
126
|
+
"r5d.2xlarge": { cpu: 8192, memory: 65536, gen: 5, ecu: 36864 },
|
127
|
+
"r5d.4xlarge": { cpu: 16384, memory: 131072, gen: 5, ecu: 73728 },
|
128
|
+
"r5d.large": { cpu: 2048, memory: 16384, gen: 5, ecu: 9216 },
|
129
|
+
"r5d.xlarge": { cpu: 4096, memory: 32768, gen: 5, ecu: 18432 },
|
130
|
+
"t1.micro": { cpu: 1024, memory: 1024, gen: 1, ecu: 1024 },
|
131
|
+
"t2.2xlarge": { cpu: 8192, memory: 32768, gen: 2, ecu: 16384 },
|
132
|
+
"t2.large": { cpu: 2048, memory: 8192, gen: 2, ecu: 4096 },
|
133
|
+
"t2.medium": { cpu: 2048, memory: 4096, gen: 2, ecu: 4096 },
|
134
|
+
"t2.micro": { cpu: 1024, memory: 1024, gen: 2, ecu: 2048 },
|
135
|
+
"t2.nano": { cpu: 1024, memory: 512, gen: 2, ecu: 2048 },
|
136
|
+
"t2.small": { cpu: 1024, memory: 2048, gen: 2, ecu: 2048 },
|
137
|
+
"t2.xlarge": { cpu: 4096, memory: 16384, gen: 2, ecu: 8192 },
|
138
|
+
"t3.2xlarge": { cpu: 8192, memory: 32768, gen: 3, ecu: 20480 },
|
139
|
+
"t3.large": { cpu: 2048, memory: 8192, gen: 3, ecu: 5120 },
|
140
|
+
"t3.medium": { cpu: 2048, memory: 4096, gen: 3, ecu: 5120 },
|
141
|
+
"t3.micro": { cpu: 1024, memory: 1024, gen: 3, ecu: 2560 },
|
142
|
+
"t3.nano": { cpu: 1024, memory: 512, gen: 3, ecu: 2560 },
|
143
|
+
"t3.small": { cpu: 1024, memory: 2048, gen: 3, ecu: 2560 },
|
144
|
+
"t3.xlarge": { cpu: 4096, memory: 16384, gen: 3, ecu: 10240 },
|
145
|
+
"x1.16xlarge": { cpu: 65536, memory: 999424, gen: 1, ecu: 163840 },
|
146
|
+
"x1.32xlarge": { cpu: 131072, memory: 1024, gen: 1, ecu: 327680 },
|
147
|
+
"x1e.16xlarge": { cpu: 65536, memory: 1024, gen: 1, ecu: 163840 },
|
148
|
+
"x1e.2xlarge": { cpu: 8192, memory: 249856, gen: 1, ecu: 20480 },
|
149
|
+
"x1e.32xlarge": { cpu: 131072, memory: 3072, gen: 1, ecu: 327680 },
|
150
|
+
"x1e.4xlarge": { cpu: 16384, memory: 499712, gen: 1, ecu: 40960 },
|
151
|
+
"x1e.8xlarge": { cpu: 32768, memory: 999424, gen: 1, ecu: 81920 },
|
152
|
+
"x1e.xlarge": { cpu: 4096, memory: 124928, gen: 1, ecu: 10240 },
|
153
|
+
"z1d.12xlarge": { cpu: 49152, memory: 393216, gen: 1, ecu: 122880 },
|
154
|
+
"z1d.2xlarge": { cpu: 8192, memory: 65536, gen: 1, ecu: 20480 },
|
155
|
+
"z1d.3xlarge": { cpu: 12288, memory: 98304, gen: 1, ecu: 30720 },
|
156
|
+
"z1d.6xlarge": { cpu: 24576, memory: 196608, gen: 1, ecu: 61440 },
|
157
|
+
"z1d.large": { cpu: 2048, memory: 16384, gen: 1, ecu: 5120 },
|
158
|
+
"z1d.xlarge": { cpu: 4096, memory: 32768, gen: 1, ecu: 10240 },
|
159
|
+
}
|
72
160
|
|
73
161
|
function pick_lowest_prices(prices)
|
74
162
|
{
|
@@ -0,0 +1,213 @@
|
|
1
|
+
var s3 = new aws.S3();
|
2
|
+
var name = request.ResourceProperties.BucketName;
|
3
|
+
var copy_from_dir = request.ResourceProperties.CopyFromDirectory;
|
4
|
+
var copy_from_bucket = request.ResourceProperties.CopyFromBucket;
|
5
|
+
var success_obj = {
|
6
|
+
Arn: "arn:aws:s3:::" + name,
|
7
|
+
DomainName: name + ".s3-" + request.ResourceProperties.Region + ".amazonaws.com"
|
8
|
+
}
|
9
|
+
var error_extra = "";
|
10
|
+
|
11
|
+
function copy_file(from, from_bucket, to, to_bucket, success, fail)
|
12
|
+
{
|
13
|
+
s3.copyObject(
|
14
|
+
{
|
15
|
+
CopySource: "/" + from_bucket + "/" + from,
|
16
|
+
Bucket: to_bucket,
|
17
|
+
Key: to
|
18
|
+
}, function(err, data)
|
19
|
+
{
|
20
|
+
if (err)
|
21
|
+
{
|
22
|
+
error_extra = "\nCopyobject: " + from + " " + from_bucket + " " + to + " " + to_bucket
|
23
|
+
fail(err);
|
24
|
+
}
|
25
|
+
else
|
26
|
+
{
|
27
|
+
success(data);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
);
|
31
|
+
}
|
32
|
+
|
33
|
+
function actually_copy_files(files_left, success, fail)
|
34
|
+
{
|
35
|
+
if (files_left.length == 0) { return success(); }
|
36
|
+
|
37
|
+
var filename = files_left.shift();
|
38
|
+
|
39
|
+
copy_file(
|
40
|
+
filename,
|
41
|
+
copy_from_bucket,
|
42
|
+
filename.replace(copy_from_dir + '/', ''),
|
43
|
+
name,
|
44
|
+
function()
|
45
|
+
{
|
46
|
+
actually_copy_files(files_left, success, fail);
|
47
|
+
},
|
48
|
+
fail
|
49
|
+
)
|
50
|
+
}
|
51
|
+
|
52
|
+
function copy_files(success, fail)
|
53
|
+
{
|
54
|
+
if (!copy_from_dir || !copy_from_bucket) { return success(); }
|
55
|
+
|
56
|
+
var files_to_copy = [];
|
57
|
+
|
58
|
+
foreach_file(
|
59
|
+
copy_from_bucket,
|
60
|
+
function(file)
|
61
|
+
{
|
62
|
+
if (file.Key.indexOf(copy_from_dir) == 0)
|
63
|
+
{
|
64
|
+
files_to_copy.push(file.Key);
|
65
|
+
}
|
66
|
+
},
|
67
|
+
function()
|
68
|
+
{
|
69
|
+
actually_copy_files(files_to_copy, success, fail);
|
70
|
+
},
|
71
|
+
fail
|
72
|
+
);
|
73
|
+
}
|
74
|
+
|
75
|
+
function create_bucket(name, success, fail)
|
76
|
+
{
|
77
|
+
var create_params = {
|
78
|
+
Bucket: name,
|
79
|
+
CreateBucketConfiguration: {
|
80
|
+
LocationConstraint: request.ResourceProperties.Region
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
s3.createBucket(create_params, function(err, data)
|
85
|
+
{
|
86
|
+
if (err)
|
87
|
+
{
|
88
|
+
fail(err);
|
89
|
+
}
|
90
|
+
else
|
91
|
+
{
|
92
|
+
copy_files(success, fail);
|
93
|
+
}
|
94
|
+
});
|
95
|
+
}
|
96
|
+
|
97
|
+
function foreach_file(name, func, success, fail)
|
98
|
+
{
|
99
|
+
var foreach_params = { Bucket: name };
|
100
|
+
|
101
|
+
s3.listObjects(foreach_params, function (err, data)
|
102
|
+
{
|
103
|
+
if (err)
|
104
|
+
{
|
105
|
+
fail(err);
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
var items = data.Contents;
|
110
|
+
|
111
|
+
for (var i = 0; i < items.length; i += 1)
|
112
|
+
{
|
113
|
+
func(items[i])
|
114
|
+
}
|
115
|
+
|
116
|
+
success();
|
117
|
+
});
|
118
|
+
}
|
119
|
+
|
120
|
+
function delete_files(name, files, success, fail)
|
121
|
+
{
|
122
|
+
var delete_files_params = {
|
123
|
+
Bucket: name,
|
124
|
+
Delete: {
|
125
|
+
Objects: files,
|
126
|
+
Quiet: false
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
if (files.length == 0)
|
131
|
+
{
|
132
|
+
// If the array has zero size, AWS throws a malformed
|
133
|
+
// XML error, which makes no sense but that is what
|
134
|
+
// happens.
|
135
|
+
return success();
|
136
|
+
}
|
137
|
+
|
138
|
+
s3.deleteObjects(delete_files_params, function(err, data)
|
139
|
+
{
|
140
|
+
if (err)
|
141
|
+
{
|
142
|
+
fail("DELETE FILES FAILED:" + err + "\n" + JSON.stringify(delete_files_params) + "\n");
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
success();
|
147
|
+
});
|
148
|
+
}
|
149
|
+
|
150
|
+
function delete_bucket(name, success, fail)
|
151
|
+
{
|
152
|
+
var delete_bucket_params = { Bucket: name };
|
153
|
+
|
154
|
+
s3.deleteBucket(delete_bucket_params, function(err, data)
|
155
|
+
{
|
156
|
+
if (err)
|
157
|
+
{
|
158
|
+
fail("DELETE BUCKET FAILED:" + err + "\n" + JSON.stringify(delete_bucket_params) + "\n");
|
159
|
+
}
|
160
|
+
else
|
161
|
+
{
|
162
|
+
success(data);
|
163
|
+
}
|
164
|
+
});
|
165
|
+
}
|
166
|
+
|
167
|
+
function send_success()
|
168
|
+
{
|
169
|
+
Cloudformation.send(request, context, Cloudformation.SUCCESS, success_obj, "Success", name);
|
170
|
+
}
|
171
|
+
|
172
|
+
function send_fail(err)
|
173
|
+
{
|
174
|
+
Cloudformation.send(request, context, Cloudformation.FAILED, {}, JSON.stringify(err) + "\n" + error_extra);
|
175
|
+
}
|
176
|
+
|
177
|
+
function delete_all_files(success, fail)
|
178
|
+
{
|
179
|
+
var objects = [];
|
180
|
+
foreach_file(
|
181
|
+
name,
|
182
|
+
function(file)
|
183
|
+
{
|
184
|
+
objects.push({ Key: file.Key });
|
185
|
+
},
|
186
|
+
function()
|
187
|
+
{
|
188
|
+
delete_files(name, objects,
|
189
|
+
function()
|
190
|
+
{
|
191
|
+
delete_bucket(name, success, fail);
|
192
|
+
},
|
193
|
+
fail
|
194
|
+
);
|
195
|
+
},
|
196
|
+
fail
|
197
|
+
)
|
198
|
+
}
|
199
|
+
|
200
|
+
if (request.RequestType == "Create")
|
201
|
+
{
|
202
|
+
create_bucket(name, send_success, send_fail);
|
203
|
+
}
|
204
|
+
|
205
|
+
if (request.RequestType == "Update")
|
206
|
+
{
|
207
|
+
send_success();
|
208
|
+
}
|
209
|
+
|
210
|
+
if (request.RequestType == "Delete")
|
211
|
+
{
|
212
|
+
delete_all_files(send_success, send_fail);
|
213
|
+
}
|