awspec 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/_resource_types/nlb.md +41 -0
- data/doc/_resource_types/nlb_listener.md +29 -0
- data/doc/_resource_types/nlb_target_group.md +35 -0
- data/doc/resource_types.md +139 -3
- data/lib/awspec/command/generate.rb +13 -1
- data/lib/awspec/generator.rb +3 -0
- data/lib/awspec/generator/doc/type/nlb.rb +20 -0
- data/lib/awspec/generator/doc/type/nlb_listener.rb +18 -0
- data/lib/awspec/generator/doc/type/nlb_target_group.rb +17 -0
- data/lib/awspec/generator/spec/nlb.rb +38 -0
- data/lib/awspec/generator/spec/rds_db_cluster_parameter_group.rb +23 -0
- data/lib/awspec/generator/spec/rds_db_parameter_group.rb +23 -0
- data/lib/awspec/helper/finder.rb +2 -0
- data/lib/awspec/helper/finder/autoscaling.rb +7 -0
- data/lib/awspec/helper/finder/nlb.rb +57 -0
- data/lib/awspec/helper/finder/rds.rb +28 -0
- data/lib/awspec/helper/type.rb +5 -3
- data/lib/awspec/matcher.rb +3 -0
- data/lib/awspec/matcher/belong_to_nlb.rb +8 -0
- data/lib/awspec/matcher/have_rule.rb +2 -1
- data/lib/awspec/stub/nlb.rb +119 -0
- data/lib/awspec/stub/nlb_listener.rb +131 -0
- data/lib/awspec/stub/nlb_target_group.rb +187 -0
- data/lib/awspec/type/autoscaling_group.rb +8 -0
- data/lib/awspec/type/nlb.rb +35 -0
- data/lib/awspec/type/nlb_listener.rb +36 -0
- data/lib/awspec/type/nlb_target_group.rb +22 -0
- data/lib/awspec/type/rds_db_cluster_parameter_group.rb +1 -14
- data/lib/awspec/type/rds_db_parameter_group.rb +1 -14
- data/lib/awspec/version.rb +1 -1
- metadata +20 -3
@@ -0,0 +1,187 @@
|
|
1
|
+
# rubocop:disable Metrics/LineLength
|
2
|
+
Aws.config[:elasticloadbalancingv2] = {
|
3
|
+
stub_responses: {
|
4
|
+
describe_load_balancers: {
|
5
|
+
load_balancers: [
|
6
|
+
{
|
7
|
+
load_balancer_arn:
|
8
|
+
'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-nlb/1aa1bb1cc1ddee11',
|
9
|
+
dns_name:
|
10
|
+
'internal-my-nlb-1551266724.ap-northeast-1.elb.amazonaws.com',
|
11
|
+
canonical_hosted_zone_id: 'A12BCDEDCBA34BC',
|
12
|
+
created_time: Time.new(2017, 4, 4, 9, 00, 00, '+00:00'),
|
13
|
+
load_balancer_name: 'my-nlb',
|
14
|
+
# scheme: 'internal',
|
15
|
+
scheme: 'internet-facing',
|
16
|
+
vpc_id: 'vpc-ab123cde',
|
17
|
+
state:
|
18
|
+
{
|
19
|
+
code: 'active',
|
20
|
+
reason: nil
|
21
|
+
},
|
22
|
+
type: 'network',
|
23
|
+
availability_zones:
|
24
|
+
[
|
25
|
+
{
|
26
|
+
zone_name: 'ap-northeast-1a',
|
27
|
+
subnet_id: 'subnet-1234a567'
|
28
|
+
},
|
29
|
+
{
|
30
|
+
zone_name: 'ap-northeast-1c',
|
31
|
+
subnet_id: 'subnet-abcd7890'
|
32
|
+
}
|
33
|
+
],
|
34
|
+
ip_address_type: 'ipv4'
|
35
|
+
}
|
36
|
+
],
|
37
|
+
next_marker: nil
|
38
|
+
},
|
39
|
+
describe_listeners: {
|
40
|
+
listeners: [
|
41
|
+
{
|
42
|
+
default_actions: [
|
43
|
+
{
|
44
|
+
target_group_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:targetgroup/my-targets/73e2d6bc24d8a067',
|
45
|
+
type: 'forward'
|
46
|
+
}
|
47
|
+
],
|
48
|
+
listener_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:listener/app/my-nlb/1aa1bb1cc1ddee11/f2f7dc8efc522ab2',
|
49
|
+
load_balancer_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-nlb/1aa1bb1cc1ddee11',
|
50
|
+
port: 80,
|
51
|
+
protocol: 'HTTP'
|
52
|
+
}
|
53
|
+
]
|
54
|
+
},
|
55
|
+
describe_target_groups: {
|
56
|
+
target_groups: [
|
57
|
+
{
|
58
|
+
health_check_interval_seconds: 30,
|
59
|
+
health_check_path: '/',
|
60
|
+
health_check_port: 'traffic-port',
|
61
|
+
health_check_protocol: 'HTTP',
|
62
|
+
health_check_timeout_seconds: 5,
|
63
|
+
healthy_threshold_count: 5,
|
64
|
+
load_balancer_arns: [
|
65
|
+
'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-nlb/1aa1bb1cc1ddee11'
|
66
|
+
],
|
67
|
+
matcher: {
|
68
|
+
http_code: '200'
|
69
|
+
},
|
70
|
+
port: 80,
|
71
|
+
protocol: 'HTTP',
|
72
|
+
target_group_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:targetgroup/my-nlb-target-group/73e2d6bc24d8a067',
|
73
|
+
target_group_name: 'my-nlb-target-group',
|
74
|
+
unhealthy_threshold_count: 2,
|
75
|
+
vpc_id: 'vpc-ab123cde'
|
76
|
+
}
|
77
|
+
]
|
78
|
+
},
|
79
|
+
describe_target_health: {
|
80
|
+
target_health_descriptions: [
|
81
|
+
{
|
82
|
+
target: {
|
83
|
+
id: 'i-0f76fade',
|
84
|
+
port: 80
|
85
|
+
},
|
86
|
+
target_health: {
|
87
|
+
description: 'Given target group is not configured to receive traffic from ELB',
|
88
|
+
reason: 'Target.NotInUse',
|
89
|
+
state: 'unused'
|
90
|
+
}
|
91
|
+
},
|
92
|
+
{
|
93
|
+
health_check_port: '80',
|
94
|
+
target: {
|
95
|
+
id: 'i-ec12345a',
|
96
|
+
port: 80
|
97
|
+
},
|
98
|
+
target_health: {
|
99
|
+
state: 'healthy'
|
100
|
+
}
|
101
|
+
}
|
102
|
+
]
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
Aws.config[:ec2] = {
|
108
|
+
stub_responses: {
|
109
|
+
describe_instances: {
|
110
|
+
reservations: [
|
111
|
+
{
|
112
|
+
instances: [
|
113
|
+
{
|
114
|
+
instance_id: 'i-ec12345a',
|
115
|
+
image_id: 'ami-abc12def',
|
116
|
+
vpc_id: 'vpc-ab123cde',
|
117
|
+
subnet_id: 'subnet-1234a567',
|
118
|
+
public_ip_address: '123.0.456.789',
|
119
|
+
private_ip_address: '10.0.1.1',
|
120
|
+
instance_type: 't2.small',
|
121
|
+
state: {
|
122
|
+
name: 'running'
|
123
|
+
},
|
124
|
+
iam_instance_profile: {
|
125
|
+
arn: 'arn:aws:iam::123456789012:instance-profile/Ec2IamProfileName',
|
126
|
+
id: 'ABCDEFGHIJKLMNOPQRSTU'
|
127
|
+
},
|
128
|
+
block_device_mappings: [
|
129
|
+
{
|
130
|
+
device_name: '/dev/sda',
|
131
|
+
ebs: {
|
132
|
+
volume_id: 'vol-123a123b'
|
133
|
+
}
|
134
|
+
}
|
135
|
+
],
|
136
|
+
network_interfaces: [
|
137
|
+
{
|
138
|
+
network_interface_id: 'eni-12ab3cde',
|
139
|
+
subnet_id: 'subnet-1234a567',
|
140
|
+
vpc_id: 'vpc-ab123cde',
|
141
|
+
attachment: {
|
142
|
+
device_index: 1
|
143
|
+
}
|
144
|
+
}
|
145
|
+
],
|
146
|
+
tags: [
|
147
|
+
{
|
148
|
+
key: 'Name',
|
149
|
+
value: 'my-ec2'
|
150
|
+
}
|
151
|
+
]
|
152
|
+
}
|
153
|
+
]
|
154
|
+
}
|
155
|
+
]
|
156
|
+
},
|
157
|
+
describe_subnets: {
|
158
|
+
subnets: [
|
159
|
+
{
|
160
|
+
state: 'available',
|
161
|
+
vpc_id: 'vpc-ab123cde',
|
162
|
+
subnet_id: 'subnet-1234a567',
|
163
|
+
cidr_block: '10.0.1.0/24',
|
164
|
+
tags: [
|
165
|
+
{
|
166
|
+
key: 'Name',
|
167
|
+
value: 'my-subnet'
|
168
|
+
}
|
169
|
+
]
|
170
|
+
}
|
171
|
+
]
|
172
|
+
},
|
173
|
+
describe_vpcs: {
|
174
|
+
vpcs: [
|
175
|
+
{
|
176
|
+
vpc_id: 'vpc-ab123cde',
|
177
|
+
tags: [
|
178
|
+
{
|
179
|
+
key: 'Name',
|
180
|
+
value: 'my-vpc'
|
181
|
+
}
|
182
|
+
]
|
183
|
+
}
|
184
|
+
]
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
@@ -42,5 +42,13 @@ module Awspec::Type
|
|
42
42
|
tg.load_balancer_target_group_arn == target_group.target_group_arn
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
def has_nlb_target_group?(id)
|
47
|
+
target_group = find_nlb_target_group(id)
|
48
|
+
target_groups = select_lb_target_group_by_autoscaling_group_name(@resource_via_client.auto_scaling_group_name)
|
49
|
+
target_groups.one? do |tg|
|
50
|
+
tg.load_balancer_target_group_arn == target_group.target_group_arn
|
51
|
+
end
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class Nlb < ResourceBase
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_nlb(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.load_balancer_name if resource_via_client
|
9
|
+
end
|
10
|
+
|
11
|
+
STATES = %w(
|
12
|
+
active provisioning failed
|
13
|
+
)
|
14
|
+
|
15
|
+
STATES.each do |state|
|
16
|
+
define_method state + '?' do
|
17
|
+
resource_via_client.state.code == state
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_security_group?(_sg_id)
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_subnet?(subnet_id)
|
26
|
+
azs = resource_via_client.availability_zones
|
27
|
+
ret = azs.find do |az|
|
28
|
+
az.subnet_id == subnet_id
|
29
|
+
end
|
30
|
+
return true if ret
|
31
|
+
subnet2 = find_subnet(subnet_id)
|
32
|
+
subnet2.subnet_id = subnet_id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class NlbListener < ResourceBase
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_nlb_listener(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.listener_arn if resource_via_client
|
9
|
+
end
|
10
|
+
|
11
|
+
def has_rule?(rule_id = nil, priority = nil, conditions = nil, actions = nil)
|
12
|
+
rules = select_rule_by_nlb_listener_id(id)
|
13
|
+
ret = rules.select do |rule|
|
14
|
+
conditions = [conditions] if conditions.is_a?(Hash)
|
15
|
+
actions = [actions] if actions.is_a?(Hash)
|
16
|
+
next false if !rule_id.nil? && rule.rule_arn != rule_id
|
17
|
+
next false if !priority.nil? && rule.priority != priority
|
18
|
+
next false if !conditions.nil? && rule.conditions.map(&:to_h).sort_by(&:to_s) != conditions.sort_by(&:to_s)
|
19
|
+
unless actions.nil?
|
20
|
+
actions = actions.map do |action|
|
21
|
+
if action.key?(:target_group_name)
|
22
|
+
target_group = find_nlb_target_group(action[:target_group_name])
|
23
|
+
action[:target_group_arn] = target_group.target_group_arn
|
24
|
+
action.delete(:target_group_name)
|
25
|
+
end
|
26
|
+
action
|
27
|
+
end
|
28
|
+
next false if rule.actions.map(&:to_h).sort_by(&:to_s) != actions.sort_by(&:to_s)
|
29
|
+
end
|
30
|
+
true
|
31
|
+
end
|
32
|
+
ret.single_resource("rule_id = #{rule_id}, priority = #{priority}, \
|
33
|
+
conditions = #{conditions}, actions = #{actions}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class NlbTargetGroup < ResourceBase
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_nlb_target_group(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.target_group_name if resource_via_client
|
9
|
+
end
|
10
|
+
|
11
|
+
def has_ec2?(id)
|
12
|
+
ec2 = find_ec2(id)
|
13
|
+
return nil unless ec2
|
14
|
+
descriptions = elbv2_client.describe_target_health(
|
15
|
+
target_group_arn: resource_via_client.target_group_arn
|
16
|
+
).target_health_descriptions
|
17
|
+
descriptions.find do |description|
|
18
|
+
description.target.id == ec2.instance_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,20 +2,7 @@ module Awspec::Type
|
|
2
2
|
class RdsDbClusterParameterGroup < ResourceBase
|
3
3
|
def resource_via_client
|
4
4
|
return @resource_via_client if @resource_via_client
|
5
|
-
|
6
|
-
parameters = {}
|
7
|
-
res = rds_client.describe_db_cluster_parameters({
|
8
|
-
db_cluster_parameter_group_name: @display_name
|
9
|
-
})
|
10
|
-
|
11
|
-
loop do
|
12
|
-
res.parameters.each do |param|
|
13
|
-
parameters[param.parameter_name] = param.parameter_value
|
14
|
-
end
|
15
|
-
(res.respond_to?(:next_page?) && res.next_page? && res = res.next_page) || break
|
16
|
-
end
|
17
|
-
|
18
|
-
@resource_via_client ||= parameters
|
5
|
+
@resource_via_client ||= select_all_rds_db_cluster_parameters(@display_name)
|
19
6
|
end
|
20
7
|
|
21
8
|
def id
|
@@ -2,20 +2,7 @@ module Awspec::Type
|
|
2
2
|
class RdsDbParameterGroup < ResourceBase
|
3
3
|
def resource_via_client
|
4
4
|
return @resource_via_client if @resource_via_client
|
5
|
-
|
6
|
-
parameters = {}
|
7
|
-
res = rds_client.describe_db_parameters({
|
8
|
-
db_parameter_group_name: @display_name
|
9
|
-
})
|
10
|
-
|
11
|
-
loop do
|
12
|
-
res.parameters.each do |param|
|
13
|
-
parameters[param.parameter_name] = param.parameter_value
|
14
|
-
end
|
15
|
-
(res.next_page? && res = res.next_page) || break
|
16
|
-
end
|
17
|
-
|
18
|
-
@resource_via_client ||= parameters
|
5
|
+
@resource_via_client ||= select_all_rds_db_parameters(@display_name)
|
19
6
|
end
|
20
7
|
|
21
8
|
def id
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -254,6 +254,9 @@ files:
|
|
254
254
|
- doc/_resource_types/nat_gateway.md
|
255
255
|
- doc/_resource_types/network_acl.md
|
256
256
|
- doc/_resource_types/network_interface.md
|
257
|
+
- doc/_resource_types/nlb.md
|
258
|
+
- doc/_resource_types/nlb_listener.md
|
259
|
+
- doc/_resource_types/nlb_target_group.md
|
257
260
|
- doc/_resource_types/rds.md
|
258
261
|
- doc/_resource_types/rds_account_attributes.md
|
259
262
|
- doc/_resource_types/rds_db_cluster_parameter_group.md
|
@@ -330,6 +333,9 @@ files:
|
|
330
333
|
- lib/awspec/generator/doc/type/nat_gateway.rb
|
331
334
|
- lib/awspec/generator/doc/type/network_acl.rb
|
332
335
|
- lib/awspec/generator/doc/type/network_interface.rb
|
336
|
+
- lib/awspec/generator/doc/type/nlb.rb
|
337
|
+
- lib/awspec/generator/doc/type/nlb_listener.rb
|
338
|
+
- lib/awspec/generator/doc/type/nlb_target_group.rb
|
333
339
|
- lib/awspec/generator/doc/type/rds.rb
|
334
340
|
- lib/awspec/generator/doc/type/rds_account_attributes.rb
|
335
341
|
- lib/awspec/generator/doc/type/rds_db_cluster_parameter_group.rb
|
@@ -368,7 +374,10 @@ files:
|
|
368
374
|
- lib/awspec/generator/spec/nat_gateway.rb
|
369
375
|
- lib/awspec/generator/spec/network_acl.rb
|
370
376
|
- lib/awspec/generator/spec/network_interface.rb
|
377
|
+
- lib/awspec/generator/spec/nlb.rb
|
371
378
|
- lib/awspec/generator/spec/rds.rb
|
379
|
+
- lib/awspec/generator/spec/rds_db_cluster_parameter_group.rb
|
380
|
+
- lib/awspec/generator/spec/rds_db_parameter_group.rb
|
372
381
|
- lib/awspec/generator/spec/route53_hosted_zone.rb
|
373
382
|
- lib/awspec/generator/spec/route_table.rb
|
374
383
|
- lib/awspec/generator/spec/s3_bucket.rb
|
@@ -405,6 +414,7 @@ files:
|
|
405
414
|
- lib/awspec/helper/finder/iam.rb
|
406
415
|
- lib/awspec/helper/finder/kms.rb
|
407
416
|
- lib/awspec/helper/finder/lambda.rb
|
417
|
+
- lib/awspec/helper/finder/nlb.rb
|
408
418
|
- lib/awspec/helper/finder/rds.rb
|
409
419
|
- lib/awspec/helper/finder/route53.rb
|
410
420
|
- lib/awspec/helper/finder/s3.rb
|
@@ -429,6 +439,7 @@ files:
|
|
429
439
|
- lib/awspec/matcher/belong_to_domain.rb
|
430
440
|
- lib/awspec/matcher/belong_to_iam_group.rb
|
431
441
|
- lib/awspec/matcher/belong_to_metric.rb
|
442
|
+
- lib/awspec/matcher/belong_to_nlb.rb
|
432
443
|
- lib/awspec/matcher/belong_to_replication_group.rb
|
433
444
|
- lib/awspec/matcher/belong_to_subnet.rb
|
434
445
|
- lib/awspec/matcher/belong_to_vpc.rb
|
@@ -493,6 +504,9 @@ files:
|
|
493
504
|
- lib/awspec/stub/nat_gateway.rb
|
494
505
|
- lib/awspec/stub/network_acl.rb
|
495
506
|
- lib/awspec/stub/network_interface.rb
|
507
|
+
- lib/awspec/stub/nlb.rb
|
508
|
+
- lib/awspec/stub/nlb_listener.rb
|
509
|
+
- lib/awspec/stub/nlb_target_group.rb
|
496
510
|
- lib/awspec/stub/rds.rb
|
497
511
|
- lib/awspec/stub/rds_db_cluster_parameter_group.rb
|
498
512
|
- lib/awspec/stub/rds_db_parameter_group.rb
|
@@ -554,6 +568,9 @@ files:
|
|
554
568
|
- lib/awspec/type/nat_gateway.rb
|
555
569
|
- lib/awspec/type/network_acl.rb
|
556
570
|
- lib/awspec/type/network_interface.rb
|
571
|
+
- lib/awspec/type/nlb.rb
|
572
|
+
- lib/awspec/type/nlb_listener.rb
|
573
|
+
- lib/awspec/type/nlb_target_group.rb
|
557
574
|
- lib/awspec/type/rds.rb
|
558
575
|
- lib/awspec/type/rds_account_attributes.rb
|
559
576
|
- lib/awspec/type/rds_db_cluster_parameter_group.rb
|
@@ -592,7 +609,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
592
609
|
version: '0'
|
593
610
|
requirements: []
|
594
611
|
rubyforge_project:
|
595
|
-
rubygems_version: 2.
|
612
|
+
rubygems_version: 2.5.2
|
596
613
|
signing_key:
|
597
614
|
specification_version: 4
|
598
615
|
summary: RSpec tests for your AWS resources.
|