awspec 0.84.0 → 0.84.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cc2bd071ea04f3b2175755926830351f496624c
4
- data.tar.gz: eb61149da8f117126acabac296f0aebee339f6f0
3
+ metadata.gz: 8913ea708bc0bd8af01f1197bc1d8783a41d9bb4
4
+ data.tar.gz: d1697374a5411d9659e057886609fc00f4f5d63e
5
5
  SHA512:
6
- metadata.gz: 2da4033f7141921eb56c5d12983864f65505a63a57c4c4a7c512994353cb40d170270c3a8aed5f8b7677547e376b23d5ffad819d84b13618b38fc2164d38e04c
7
- data.tar.gz: f0ae057b8e2e7cfe943f00032b73f1e502ba295ad5c395cde0183c5d2d531f429e004d427ccc3746fd1fce77284b6bb0b6dfd48c8bf98d12d0e2afc1675da12c
6
+ metadata.gz: ab84648f8284d3391d546958f5fd3c171e7ecbb30b72daab9b7e8049a104663683c1d228e2080d5f57cc04299e65f1982e8c97e678d084ac53aad1a46d907686
7
+ data.tar.gz: 0b9178cdcf47a9046ca84ef6e003f08679820c9d38ae77ead3810423ac59b4ff562382fc53be34a981d8903d29991228778005d6ace259d273a510d2daa17c24
@@ -1,4 +1,4 @@
1
- # exist
1
+ ### exist
2
2
 
3
3
  ```ruby
4
4
  describe alb_target_group('my-alb-target-group') do
@@ -5,6 +5,13 @@ describe autoscaling_group('my-auto-scaling-group') do
5
5
  it { should exist }
6
6
  end
7
7
  ```
8
+ ### have_alb_target_group
9
+
10
+ ```ruby
11
+ describe autoscaling_group('my-auto-scaling-group') do
12
+ it { should have_alb_target_group('my-alb-target-group') }
13
+ end
14
+ ```
8
15
 
9
16
  ### have_ec2
10
17
 
@@ -1,4 +1,4 @@
1
- # exist
1
+ ### exist
2
2
 
3
3
  ```ruby
4
4
  describe waf_web_acl('my-waf-web-acl') do
@@ -162,6 +162,16 @@ AlbTargetGroup resource type.
162
162
 
163
163
  ### exist
164
164
 
165
+ ```ruby
166
+ describe alb_target_group('my-alb-target-group') do
167
+ it { should exist }
168
+ its(:health_check_path) { should eq '/' }
169
+ its(:health_check_port) { should eq 'traffic-port' }
170
+ its(:health_check_protocol) { should eq 'HTTP' }
171
+ end
172
+ ```
173
+
174
+
165
175
  ### have_ec2
166
176
 
167
177
  ```ruby
@@ -231,6 +241,14 @@ describe autoscaling_group('my-auto-scaling-group') do
231
241
  end
232
242
  ```
233
243
 
244
+ ### have_alb_target_group
245
+
246
+ ```ruby
247
+ describe autoscaling_group('my-auto-scaling-group') do
248
+ it { should have_alb_target_group('my-alb-target-group') }
249
+ end
250
+ ```
251
+
234
252
 
235
253
  ### have_ec2
236
254
 
@@ -2529,6 +2547,16 @@ WafWebAcl resource type.
2529
2547
 
2530
2548
  ### exist
2531
2549
 
2550
+ ```ruby
2551
+ describe waf_web_acl('my-waf-web-acl') do
2552
+ it { should exist }
2553
+ its(:default_action) { should eq 'BLOCK' }
2554
+ it { should have_rule('my-waf-web-acl-allowed-ips') }
2555
+ it { should have_rule('my-waf-web-acl-allowed-ips').order(2).action('BLOCK') }
2556
+ end
2557
+ ```
2558
+
2559
+
2532
2560
  ### have_rule
2533
2561
 
2534
2562
  ```ruby
@@ -116,7 +116,7 @@ EOF
116
116
  def self.generate_resource_type_doc
117
117
  path = 'doc/_resource_types/' + @type.underscore + '.md'
118
118
  content = <<-"EOF"
119
- # exist
119
+ ### exist
120
120
  EOF
121
121
  self.file_check_and_puts(path, content)
122
122
  end
@@ -15,6 +15,13 @@ module Awspec::Helper
15
15
  res.launch_configurations.single_resource(id)
16
16
  end
17
17
 
18
+ def select_alb_target_group_by_autoscaling_group_name(name)
19
+ res = autoscaling_client.describe_load_balancer_target_groups({
20
+ auto_scaling_group_name: name
21
+ })
22
+ res.load_balancer_target_groups
23
+ end
24
+
18
25
  def find_block_device_mapping(id, device_id)
19
26
  ret = find_launch_configuration(id).block_device_mappings.select do |device|
20
27
  next true if device.device_name == device_id
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/LineLength
1
2
  Aws.config[:autoscaling] = {
2
3
  stub_responses: {
3
4
  describe_auto_scaling_groups: {
@@ -71,6 +72,119 @@ Aws.config[:autoscaling] = {
71
72
  value: 'WebServer'
72
73
  }
73
74
  ]
75
+ },
76
+ describe_load_balancer_target_groups: {
77
+ load_balancer_target_groups: [
78
+ {
79
+ load_balancer_target_group_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:123456789012:targetgroup/73e2d6bc24d8a067/73e2d6bc24d8a067',
80
+ state: 'Added'
81
+ }
82
+ ]
83
+ }
84
+ }
85
+ }
86
+
87
+ Aws.config[:elasticloadbalancingv2] = {
88
+ stub_responses: {
89
+ describe_load_balancers: {
90
+ load_balancers: [
91
+ {
92
+ load_balancer_arn:
93
+ 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-alb/1aa1bb1cc1ddee11',
94
+ dns_name:
95
+ 'internal-my-elb-1551266724.ap-northeast-1.elb.amazonaws.com',
96
+ canonical_hosted_zone_id: 'A12BCDEDCBA34BC',
97
+ created_time: Time.new(2017, 4, 4, 9, 00, 00, '+00:00'),
98
+ load_balancer_name: 'my-alb',
99
+ scheme: 'internal',
100
+ vpc_id: 'vpc-ab123cde',
101
+ state:
102
+ {
103
+ code: 'active',
104
+ reason: nil
105
+ },
106
+ type: 'application',
107
+ availability_zones:
108
+ [
109
+ {
110
+ zone_name: 'ap-northeast-1a',
111
+ subnet_id: 'subnet-1234a567'
112
+ },
113
+ {
114
+ zone_name: 'ap-northeast-1c',
115
+ subnet_id: 'subnet-abcd7890'
116
+ }
117
+ ],
118
+ security_groups: ['sg-1a2b3cd4'],
119
+ ip_address_type: 'ipv4'
120
+ }
121
+ ],
122
+ next_marker: nil
123
+ },
124
+ describe_listeners: {
125
+ listeners: [
126
+ {
127
+ default_actions: [
128
+ {
129
+ target_group_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:targetgroup/my-targets/73e2d6bc24d8a067',
130
+ type: 'forward'
131
+ }
132
+ ],
133
+ listener_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:listener/app/my-alb/1aa1bb1cc1ddee11/f2f7dc8efc522ab2',
134
+ load_balancer_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-alb/1aa1bb1cc1ddee11',
135
+ port: 80,
136
+ protocol: 'HTTP'
137
+ }
138
+ ]
139
+ },
140
+ describe_target_groups: {
141
+ target_groups: [
142
+ {
143
+ health_check_interval_seconds: 30,
144
+ health_check_path: '/',
145
+ health_check_port: 'traffic-port',
146
+ health_check_protocol: 'HTTP',
147
+ health_check_timeout_seconds: 5,
148
+ healthy_threshold_count: 5,
149
+ load_balancer_arns: [
150
+ 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:loadbalancer/app/my-alb/1aa1bb1cc1ddee11'
151
+ ],
152
+ matcher: {
153
+ http_code: '200'
154
+ },
155
+ port: 80,
156
+ protocol: 'HTTP',
157
+ target_group_arn: 'arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:123456789012:targetgroup/73e2d6bc24d8a067/73e2d6bc24d8a067',
158
+ target_group_name: 'my-alb-target-group',
159
+ unhealthy_threshold_count: 2,
160
+ vpc_id: 'vpc-ab123cde'
161
+ }
162
+ ]
163
+ },
164
+ describe_target_health: {
165
+ target_health_descriptions: [
166
+ {
167
+ target: {
168
+ id: 'i-0f76fade',
169
+ port: 80
170
+ },
171
+ target_health: {
172
+ description: 'Given target group is not configured to receive traffic from ELB',
173
+ reason: 'Target.NotInUse',
174
+ state: 'unused'
175
+ }
176
+ },
177
+ {
178
+ health_check_port: '80',
179
+ target: {
180
+ id: 'i-ec12345a',
181
+ port: 80
182
+ },
183
+ target_health: {
184
+ state: 'healthy'
185
+ }
186
+ }
187
+ ]
74
188
  }
75
189
  }
76
190
  }
@@ -12,7 +12,7 @@ module Awspec::Type
12
12
  end
13
13
 
14
14
  def has_elb?(name)
15
- resource_via_client.load_balancer_names.find do |lb_name|
15
+ resource_via_client.load_balancer_names.one? do |lb_name|
16
16
  lb_name == name
17
17
  end
18
18
  end
@@ -20,15 +20,23 @@ module Awspec::Type
20
20
  def has_ec2?(id)
21
21
  ec2 = find_ec2(id)
22
22
  return nil unless ec2
23
- resource_via_client.instances.find do |instance|
24
- instance.instance_id = ec2.instance_id
23
+ resource_via_client.instances.one? do |instance|
24
+ instance.instance_id == ec2.instance_id
25
25
  end
26
26
  end
27
27
 
28
28
  def has_suspended_process?(id)
29
- resource_via_client.suspended_processes.find do |process|
29
+ resource_via_client.suspended_processes.one? do |process|
30
30
  process.process_name == id
31
31
  end
32
32
  end
33
+
34
+ def has_alb_target_group?(id)
35
+ target_group = find_alb_target_group(id)
36
+ target_groups = select_alb_target_group_by_autoscaling_group_name(@resource_via_client.auto_scaling_group_name)
37
+ target_groups.one? do |tg|
38
+ tg.load_balancer_target_group_arn == target_group.target_group_arn
39
+ end
40
+ end
33
41
  end
34
42
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.84.0'
2
+ VERSION = '0.84.1'
3
3
  end
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: 0.84.0
4
+ version: 0.84.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec