kumogata-template 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -19
- data/lib/kumogata/template/alb.rb +99 -0
- data/lib/kumogata/template/certificate.rb +18 -0
- data/lib/kumogata/template/const.rb +7 -0
- data/lib/kumogata/template/ec2.rb +6 -0
- data/lib/kumogata/template/ecs.rb +9 -0
- data/lib/kumogata/template/ext/kumogata.rb +5 -6
- data/lib/kumogata/template/helper.rb +4 -0
- data/lib/kumogata/template/version.rb +1 -1
- data/lib/kumogata/template.rb +2 -0
- data/template/alb-listener-rule.rb +22 -0
- data/template/alb-listener.rb +26 -0
- data/template/alb-load-balancer.rb +27 -0
- data/template/alb-target-group.rb +39 -0
- data/template/autoscaling-group.rb +2 -0
- data/template/certificate.rb +20 -0
- data/template/ec2-flow-log.rb +41 -0
- data/template/ec2-host.rb +21 -0
- data/template/ec2-instance.rb +5 -1
- data/template/ec2-spot-fleet.rb +16 -0
- data/template/ecs-service.rb +2 -0
- data/template/{elb-loadbalancer.rb → elb-load-balancer.rb} +1 -1
- data/template/iam-group.rb +2 -0
- data/template/iam-role.rb +11 -0
- data/template/iam-user.rb +2 -0
- data/template/output-alb.rb +21 -0
- data/template/output-elb.rb +4 -0
- data/template/parameter-ec2.rb +4 -4
- data/test/alb_test.rb +25 -0
- data/test/ec2_test.rb +45 -0
- data/test/helper_test.rb +21 -0
- data/test/template/alb-listener-rule_test.rb +40 -0
- data/test/template/alb-listener_test.rb +33 -0
- data/test/template/alb-load-balancer_test.rb +72 -0
- data/test/template/alb-target-group_test.rb +89 -0
- data/test/template/certificate_test.rb +27 -0
- data/test/template/ec2-flow-log_test.rb +26 -0
- data/test/template/ec2-host_test.rb +23 -0
- data/test/template/ec2-spot-fleet_test.rb +173 -0
- data/test/template/{elb-loadbalancer_test.rb → elb-load-balancer_test.rb} +1 -1
- data/test/template/output-alb_test.rb +105 -0
- data/test/template/output-elb_test.rb +61 -0
- data/test/template/parameter-ec2_test.rb +38 -9
- metadata +36 -5
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Output alb
|
3
|
+
#
|
4
|
+
|
5
|
+
_output "#{args[:name]} load balancer",
|
6
|
+
ref_value: "#{args[:name]} load balancer"
|
7
|
+
_output "#{args[:name]} load balancer dns name",
|
8
|
+
ref_value: [ "#{args[:name]} load balancer", "DNSName" ]
|
9
|
+
_output "#{args[:name]} load balancer canonical hosted zone id",
|
10
|
+
ref_value: [ "#{args[:name]} load balancer", "CanonicalHostedZoneID" ] if args.key? :route53
|
11
|
+
_output "#{args[:name]} load balancer full name",
|
12
|
+
ref_value: [ "#{args[:name]} load balancer", "LoadBalancerFullName" ]
|
13
|
+
_output "#{args[:name]} load balancer name",
|
14
|
+
ref_value: [ "#{args[:name]} load balancer", "LoadBalancerName" ]
|
15
|
+
|
16
|
+
if args.key? :security_groups
|
17
|
+
args[:security_groups].times do |i|
|
18
|
+
_output "#{args[:name]} load balancer security group #{i}",
|
19
|
+
value: _select(i, _attr_string(args[:name], "SecurityGroups", "load balancer"))
|
20
|
+
end
|
21
|
+
end
|
data/template/output-elb.rb
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
_output "#{args[:name]} load balancer",
|
6
6
|
ref_value: "#{args[:name]} load balancer"
|
7
|
+
_output "#{args[:name]} load balancer canonical hosted zone name",
|
8
|
+
ref_value: [ "#{args[:name]} load balancer", "CanonicalHostedZoneName" ] if args.key? :route53
|
9
|
+
_output "#{args[:name]} load balancer canonical hosted zone id",
|
10
|
+
ref_value: [ "#{args[:name]} load balancer", "CanonicalHostedZoneID" ] if args.key? :route53
|
7
11
|
_output "#{args[:name]} load balancer dns name",
|
8
12
|
ref_value: [ "#{args[:name]} load balancer", "DNSName" ]
|
9
13
|
_output "#{args[:name]} load balancer security group name",
|
data/template/parameter-ec2.rb
CHANGED
@@ -9,14 +9,14 @@ _parameter "#{args[:name]} instance type",
|
|
9
9
|
allowed_values: EC2_INSTANCE_TYPES
|
10
10
|
|
11
11
|
_parameter "#{args[:name]} iam instance profile",
|
12
|
-
default: args[:iam_instance]
|
13
|
-
description: "#{args[:name]} iam instance profile"
|
12
|
+
default: args[:iam_instance],
|
13
|
+
description: "#{args[:name]} iam instance profile" if args.key? :iam_instance
|
14
14
|
|
15
15
|
_parameter "#{args[:name]} data volume size",
|
16
16
|
default: args[:size] || 100,
|
17
17
|
description: "#{args[:name]} data volume size"
|
18
18
|
|
19
19
|
_parameter "#{args[:name]} key name",
|
20
|
-
default: args[:
|
20
|
+
default: args[:key_name],
|
21
21
|
description: "#{args[:name]} key name",
|
22
|
-
type: "AWS::EC2::KeyPair::KeyName"
|
22
|
+
type: "AWS::EC2::KeyPair::KeyName" if args.key? :key_name
|
data/test/alb_test.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'kumogata/template/alb'
|
3
|
+
|
4
|
+
class AlbTest < Minitest::Test
|
5
|
+
def test_alb_health_check
|
6
|
+
template = <<-EOS
|
7
|
+
Test _alb_health_check({})
|
8
|
+
EOS
|
9
|
+
act_template = run_client_as_json(template)
|
10
|
+
exp_template = <<-EOS
|
11
|
+
{
|
12
|
+
"Test": {
|
13
|
+
"interval": 30,
|
14
|
+
"path": "/",
|
15
|
+
"port": 80,
|
16
|
+
"protocol": "HTTP",
|
17
|
+
"timeout": 5,
|
18
|
+
"healthy": 10,
|
19
|
+
"unhealthly": 2
|
20
|
+
}
|
21
|
+
}
|
22
|
+
EOS
|
23
|
+
assert_equal exp_template.chomp, act_template
|
24
|
+
end
|
25
|
+
end
|
data/test/ec2_test.rb
CHANGED
@@ -113,6 +113,26 @@ Test _ec2_tags(name: "test", tags_append: { ref_test: "test" })
|
|
113
113
|
def test_ec2_security_group_egresses
|
114
114
|
template = <<-EOS
|
115
115
|
args = { egress: [ to: 80, group: "test" ] }
|
116
|
+
Test _ec2_security_group_egresses("egress", args)
|
117
|
+
EOS
|
118
|
+
act_template = run_client_as_json(template)
|
119
|
+
exp_template = <<-EOS
|
120
|
+
{
|
121
|
+
"Test": [
|
122
|
+
{
|
123
|
+
"CidrIp": "0.0.0.0/0",
|
124
|
+
"FromPort": "80",
|
125
|
+
"GroupId": "test",
|
126
|
+
"IpProtocol": "tcp",
|
127
|
+
"ToPort": "80"
|
128
|
+
}
|
129
|
+
]
|
130
|
+
}
|
131
|
+
EOS
|
132
|
+
assert_equal exp_template.chomp, act_template
|
133
|
+
|
134
|
+
template = <<-EOS
|
135
|
+
args = { egress: [ to: 80, group: "test" ] }
|
116
136
|
Test _ec2_security_group_egresses("egress", args)
|
117
137
|
EOS
|
118
138
|
act_template = run_client_as_json(template)
|
@@ -167,6 +187,31 @@ Test _ec2_security_group_ingresses("ingress", args)
|
|
167
187
|
"ToPort": "80"
|
168
188
|
}
|
169
189
|
]
|
190
|
+
}
|
191
|
+
EOS
|
192
|
+
assert_equal exp_template.chomp, act_template
|
193
|
+
|
194
|
+
template = <<-EOS
|
195
|
+
args = { ingress: [ 22, 80 ] }
|
196
|
+
Test _ec2_security_group_ingresses("ingress", args)
|
197
|
+
EOS
|
198
|
+
act_template = run_client_as_json(template)
|
199
|
+
exp_template = <<-EOS
|
200
|
+
{
|
201
|
+
"Test": [
|
202
|
+
{
|
203
|
+
"CidrIp": "0.0.0.0/0",
|
204
|
+
"FromPort": "22",
|
205
|
+
"IpProtocol": "tcp",
|
206
|
+
"ToPort": "22"
|
207
|
+
},
|
208
|
+
{
|
209
|
+
"CidrIp": "0.0.0.0/0",
|
210
|
+
"FromPort": "80",
|
211
|
+
"IpProtocol": "tcp",
|
212
|
+
"ToPort": "80"
|
213
|
+
}
|
214
|
+
]
|
170
215
|
}
|
171
216
|
EOS
|
172
217
|
assert_equal exp_template.chomp, act_template
|
data/test/helper_test.rb
CHANGED
@@ -255,6 +255,27 @@ Test _find_in_map("Test", "test1", "test2")
|
|
255
255
|
assert_equal exp_template.chomp, act_template
|
256
256
|
end
|
257
257
|
|
258
|
+
def test_select
|
259
|
+
template = <<-EOS
|
260
|
+
Test _select(1, %w( test1 test2 ))
|
261
|
+
EOS
|
262
|
+
act_template = run_client_as_json(template)
|
263
|
+
exp_template = <<-EOS
|
264
|
+
{
|
265
|
+
"Test": {
|
266
|
+
"Fn::Select": [
|
267
|
+
"1",
|
268
|
+
[
|
269
|
+
"test1",
|
270
|
+
"test2"
|
271
|
+
]
|
272
|
+
]
|
273
|
+
}
|
274
|
+
}
|
275
|
+
EOS
|
276
|
+
assert_equal exp_template.chomp, act_template
|
277
|
+
end
|
278
|
+
|
258
279
|
def test_tag
|
259
280
|
template = <<-EOS
|
260
281
|
Test _tag(key: "test", value: "test")
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AlbListenerRuleTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_alb_listener_rule "test", actions: [ { ref_target: "test" } ], ref_listener: "test", conditions: [ [ "/img/*" ] ]
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestLoadBalancerListenerRule": {
|
12
|
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
13
|
+
"Properties": {
|
14
|
+
"Actions": [
|
15
|
+
{
|
16
|
+
"TargetGroupArn": {
|
17
|
+
"Ref": "TestTargetGroup"
|
18
|
+
},
|
19
|
+
"Type": "forward"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"Conditions": [
|
23
|
+
{
|
24
|
+
"Field": "path-pattern",
|
25
|
+
"Values": [
|
26
|
+
"/img/*"
|
27
|
+
]
|
28
|
+
}
|
29
|
+
],
|
30
|
+
"ListenerArn": {
|
31
|
+
"Ref": "TestLoadBalancerListener"
|
32
|
+
},
|
33
|
+
"Priority": "1"
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
EOS
|
38
|
+
assert_equal exp_template.chomp, act_template
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AlbListenerTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_alb_listener "test", actions: [ { ref_target: "test" } ], ref_lb: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestLoadBalancerListener": {
|
12
|
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
13
|
+
"Properties": {
|
14
|
+
"DefaultActions": [
|
15
|
+
{
|
16
|
+
"TargetGroupArn": {
|
17
|
+
"Ref": "TestTargetGroup"
|
18
|
+
},
|
19
|
+
"Type": "forward"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"LoadBalancerArn": {
|
23
|
+
"Ref": "TestLoadBalancer"
|
24
|
+
},
|
25
|
+
"Port": "80",
|
26
|
+
"Protocol": "HTTP"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
EOS
|
31
|
+
assert_equal exp_template.chomp, act_template
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AlbLoadbalancerTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_alb_load_balancer "test", attributes: [ { "test": "test" } ], ref_security_groups: [ "test" ]
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestLoadBalancer": {
|
12
|
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
13
|
+
"Properties": {
|
14
|
+
"LoadBalancerAttributes": [
|
15
|
+
{
|
16
|
+
"Key": "test",
|
17
|
+
"Value": "test"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"Name": {
|
21
|
+
"Fn::Join": [
|
22
|
+
"-",
|
23
|
+
[
|
24
|
+
{
|
25
|
+
"Ref": "Service"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"Ref": "Name"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
]
|
32
|
+
},
|
33
|
+
"SecurityGroups": [
|
34
|
+
{
|
35
|
+
"Ref": "TestSecurityGroup"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"Tags": [
|
39
|
+
{
|
40
|
+
"Key": "Name",
|
41
|
+
"Value": {
|
42
|
+
"Fn::Join": [
|
43
|
+
"-",
|
44
|
+
[
|
45
|
+
{
|
46
|
+
"Ref": "Service"
|
47
|
+
},
|
48
|
+
"test"
|
49
|
+
]
|
50
|
+
]
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"Key": "Service",
|
55
|
+
"Value": {
|
56
|
+
"Ref": "Service"
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"Key": "Version",
|
61
|
+
"Value": {
|
62
|
+
"Ref": "Version"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
EOS
|
70
|
+
assert_equal exp_template.chomp, act_template
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class AlbTargetGroupTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_alb_target_group "test", attributes: [ { key: "value" } ], targets: [ { ref_instance: "test" } ], ref_vpc: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestTargetGroup": {
|
12
|
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
13
|
+
"Properties": {
|
14
|
+
"HealthCheckIntervalSeconds": "30",
|
15
|
+
"HealthCheckPath": "/",
|
16
|
+
"HealthCheckPort": "80",
|
17
|
+
"HealthCheckProtocol": "HTTP",
|
18
|
+
"HealthCheckTimeoutSeconds": "5",
|
19
|
+
"HealthyThresholdCount": "10",
|
20
|
+
"Matcher": {
|
21
|
+
"HttpCode": "200"
|
22
|
+
},
|
23
|
+
"Name": {
|
24
|
+
"Fn::Join": [
|
25
|
+
"-",
|
26
|
+
[
|
27
|
+
{
|
28
|
+
"Ref": "Service"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"Ref": "Name"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
]
|
35
|
+
},
|
36
|
+
"Port": "80",
|
37
|
+
"Protocol": "HTTP",
|
38
|
+
"Tags": [
|
39
|
+
{
|
40
|
+
"Key": "Name",
|
41
|
+
"Value": {
|
42
|
+
"Fn::Join": [
|
43
|
+
"-",
|
44
|
+
[
|
45
|
+
{
|
46
|
+
"Ref": "Service"
|
47
|
+
},
|
48
|
+
"test"
|
49
|
+
]
|
50
|
+
]
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"Key": "Service",
|
55
|
+
"Value": {
|
56
|
+
"Ref": "Service"
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"Key": "Version",
|
61
|
+
"Value": {
|
62
|
+
"Ref": "Version"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
],
|
66
|
+
"TargetGroupAttributes": [
|
67
|
+
{
|
68
|
+
"Key": "key",
|
69
|
+
"Value": "value"
|
70
|
+
}
|
71
|
+
],
|
72
|
+
"Targets": [
|
73
|
+
{
|
74
|
+
"Id": {
|
75
|
+
"Ref": "TestInstance"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"UnhealthyThresholdCount": "2",
|
80
|
+
"VpcId": {
|
81
|
+
"Ref": "TestVpc"
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
EOS
|
87
|
+
assert_equal exp_template.chomp, act_template
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class CertificateTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_certificate "test", domain: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestCertificate": {
|
12
|
+
"Type": "AWS::CertificateManager::Certificate",
|
13
|
+
"Properties": {
|
14
|
+
"DomainName": "test",
|
15
|
+
"DomainValidationOptions": [
|
16
|
+
{
|
17
|
+
"DomainName": "test",
|
18
|
+
"ValidationDomain": "test"
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
EOS
|
25
|
+
assert_equal exp_template.chomp, act_template
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class Ec2LowLogTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_ec2_flow_log "test", ref_id: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestFlowLog": {
|
12
|
+
"Type": "AWS::EC2::FlowLog",
|
13
|
+
"Properties": {
|
14
|
+
"LogGroupName": "test",
|
15
|
+
"ResourceId": {
|
16
|
+
"Ref": "TestVpc"
|
17
|
+
},
|
18
|
+
"ResourceType": "VPC",
|
19
|
+
"TrafficType": "ALL"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
EOS
|
24
|
+
assert_equal exp_template.chomp, act_template
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class Ec2HostTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
_ec2_host "test", auto: "on", az: "test"
|
7
|
+
EOS
|
8
|
+
act_template = run_client_as_json(template)
|
9
|
+
exp_template = <<-EOS
|
10
|
+
{
|
11
|
+
"TestHost": {
|
12
|
+
"Type": "AWS::EC2::Host",
|
13
|
+
"Properties": {
|
14
|
+
"AutoPlacement": "on",
|
15
|
+
"AvailabilityZone": "test",
|
16
|
+
"InstanceType": "c4.large"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
EOS
|
21
|
+
assert_equal exp_template.chomp, act_template
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class Ec2SpotFeetTest < Minitest::Test
|
4
|
+
def test_normal
|
5
|
+
template = <<-EOS
|
6
|
+
launches = [
|
7
|
+
{ block_devices: [ { ref_size: "test" } ],
|
8
|
+
ref_iam: "test", image_id: "test", ref_key_name: "test", instance_type: "test", network_interfaces: [ { ref_subnet: "test" } ] }
|
9
|
+
]
|
10
|
+
_ec2_spot_fleet "test", iam: "test", price: 1000, ref_taget: "test", launches: launches, target: 1
|
11
|
+
EOS
|
12
|
+
act_template = run_client_as_json(template)
|
13
|
+
exp_template = <<-EOS
|
14
|
+
{
|
15
|
+
"TestSpotFleet": {
|
16
|
+
"Type": "AWS::EC2::SpotFleet",
|
17
|
+
"Properties": {
|
18
|
+
"SpotFleetRequestConfigData": {
|
19
|
+
"AllocationStrategy": "lowestPrice",
|
20
|
+
"IamFleetRole": "test",
|
21
|
+
"LaunchSpecifications": [
|
22
|
+
{
|
23
|
+
"BlockDeviceMappings": [
|
24
|
+
{
|
25
|
+
"DeviceName": "/dev/sda1",
|
26
|
+
"Ebs": {
|
27
|
+
"DeleteOnTermination": "true",
|
28
|
+
"VolumeSize": {
|
29
|
+
"Ref": "TestVolumeSize"
|
30
|
+
},
|
31
|
+
"VolumeType": "gp2"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"EbsOptimized": "false",
|
36
|
+
"IamInstanceProfile": {
|
37
|
+
"Arn": {
|
38
|
+
"Ref": "TestIamInstanceProfile"
|
39
|
+
}
|
40
|
+
},
|
41
|
+
"ImageId": "test",
|
42
|
+
"InstanceType": "test",
|
43
|
+
"KeyName": {
|
44
|
+
"Ref": "TestKeyName"
|
45
|
+
},
|
46
|
+
"Monitoring": {
|
47
|
+
"Enabled": "false"
|
48
|
+
},
|
49
|
+
"NetworkInterfaces": [
|
50
|
+
{
|
51
|
+
"AssociatePublicIpAddress": "true",
|
52
|
+
"DeleteOnTermination": "true",
|
53
|
+
"DeviceIndex": "0",
|
54
|
+
"SubnetId": {
|
55
|
+
"Ref": "TestSubnet"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
],
|
61
|
+
"SpotPrice": "1000",
|
62
|
+
"TargetCapacity": "1",
|
63
|
+
"TerminateInstancesWithExpiration": "false"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
EOS
|
69
|
+
assert_equal exp_template.chomp, act_template
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_aws
|
73
|
+
template = <<-EOS
|
74
|
+
launches = [
|
75
|
+
{ ebs: false, ref_instance_type: "test", image: "test", ref_subnet: "subnet1", weighted: 8 },
|
76
|
+
{ ebs: true, ref_instance_type: "test", image: "test", ref_subnet: "subnet0", weighted: 8, monitoring: true, ref_security_groups: [ "test" ], ref_iam: "root" },
|
77
|
+
]
|
78
|
+
_ec2_spot_fleet "test", iam: "test", price: 1000, ref_target: "target capacity", launches: launches
|
79
|
+
EOS
|
80
|
+
act_template = run_client_as_json(template)
|
81
|
+
exp_template = <<-EOS
|
82
|
+
{
|
83
|
+
"TestSpotFleet": {
|
84
|
+
"Type": "AWS::EC2::SpotFleet",
|
85
|
+
"Properties": {
|
86
|
+
"SpotFleetRequestConfigData": {
|
87
|
+
"AllocationStrategy": "lowestPrice",
|
88
|
+
"IamFleetRole": "test",
|
89
|
+
"LaunchSpecifications": [
|
90
|
+
{
|
91
|
+
"EbsOptimized": "false",
|
92
|
+
"ImageId": {
|
93
|
+
"Fn::FindInMap": [
|
94
|
+
"AWSRegionArch2AMITest",
|
95
|
+
{
|
96
|
+
"Ref": "AWS::Region"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"Fn::FindInMap": [
|
100
|
+
"AWSInstanceType2Arch",
|
101
|
+
{
|
102
|
+
"Ref": "TestInstanceType"
|
103
|
+
},
|
104
|
+
"Arch"
|
105
|
+
]
|
106
|
+
}
|
107
|
+
]
|
108
|
+
},
|
109
|
+
"InstanceType": {
|
110
|
+
"Ref": "TestInstanceType"
|
111
|
+
},
|
112
|
+
"Monitoring": {
|
113
|
+
"Enabled": "false"
|
114
|
+
},
|
115
|
+
"SubnetId": {
|
116
|
+
"Ref": "Subnet1Subnet"
|
117
|
+
},
|
118
|
+
"WeightedCapacity": "8"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"EbsOptimized": "true",
|
122
|
+
"IamInstanceProfile": {
|
123
|
+
"Arn": {
|
124
|
+
"Ref": "RootIamInstanceProfile"
|
125
|
+
}
|
126
|
+
},
|
127
|
+
"ImageId": {
|
128
|
+
"Fn::FindInMap": [
|
129
|
+
"AWSRegionArch2AMITest",
|
130
|
+
{
|
131
|
+
"Ref": "AWS::Region"
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"Fn::FindInMap": [
|
135
|
+
"AWSInstanceType2Arch",
|
136
|
+
{
|
137
|
+
"Ref": "TestInstanceType"
|
138
|
+
},
|
139
|
+
"Arch"
|
140
|
+
]
|
141
|
+
}
|
142
|
+
]
|
143
|
+
},
|
144
|
+
"InstanceType": {
|
145
|
+
"Ref": "TestInstanceType"
|
146
|
+
},
|
147
|
+
"Monitoring": {
|
148
|
+
"Enabled": "true"
|
149
|
+
},
|
150
|
+
"SecurityGroups": [
|
151
|
+
{
|
152
|
+
"Ref": "TestSecurityGroup"
|
153
|
+
}
|
154
|
+
],
|
155
|
+
"SubnetId": {
|
156
|
+
"Ref": "Subnet0Subnet"
|
157
|
+
},
|
158
|
+
"WeightedCapacity": "8"
|
159
|
+
}
|
160
|
+
],
|
161
|
+
"SpotPrice": "1000",
|
162
|
+
"TargetCapacity": {
|
163
|
+
"Ref": "TargetCapacity"
|
164
|
+
},
|
165
|
+
"TerminateInstancesWithExpiration": "false"
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
EOS
|
171
|
+
assert_equal exp_template.chomp, act_template
|
172
|
+
end
|
173
|
+
end
|
@@ -3,7 +3,7 @@ require 'abstract_unit'
|
|
3
3
|
class ElbLoadbalancerTest < Minitest::Test
|
4
4
|
def test_normal
|
5
5
|
template = <<-EOS
|
6
|
-
|
6
|
+
_elb_load_balancer "test", ref_security_groups: [ "test" ], listeners: [ protocol: "http" ]
|
7
7
|
EOS
|
8
8
|
act_template = run_client_as_json(template)
|
9
9
|
exp_template = <<-EOS
|