awspec 1.12.5 → 1.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 797c0a76eedaac924e9fae9b797ef5aa145db194897b20a71e4d8b1d8c61572c
4
- data.tar.gz: ea9b100cac9a2e284add01af86f01b081cfdb95a2654c8fe938f3714eedcc778
3
+ metadata.gz: fd344eca7cdef535b7e962fddd4214c3af86de326cb9fe02b5ded97356c0d709
4
+ data.tar.gz: a7bb40c492a2fc190f978a4925376385bbc3b2289c0a51efa18ebbb49a38f50d
5
5
  SHA512:
6
- metadata.gz: 52e51107ea7b8c30ab9500e416ecd7d058853c890a403b48d6a8154356bcce0109b3762da60fc7ca3e7045c79805bb012ac764b42df018f6a6f51434c188ca08
7
- data.tar.gz: 2be23ba27f8cb3b5bd907749b0ba60075b4729ab8e8d4f4d0992a16eb7be784ea6dab2d69b408e736a3b652a1fbd985a598d00576bceb074076d42b5b845cd31
6
+ metadata.gz: d878ba90f5809d6a8f76ceea08fc94b59f5da8e42cf8e3a4b7546df8874fc107a4497479655f35e4b87c5007fae6e485c28abdc0c6a834f1a77329d83705acaa
7
+ data.tar.gz: 02666bd47a44b756f38829136b024de943f4cc2838c1aef9307857f3d7125b33c6659ce1501db060c5739ed750a139d99553fc97c5d96811a63034bba23c3172
@@ -1763,7 +1763,7 @@ end
1763
1763
  ```
1764
1764
 
1765
1765
 
1766
- ### its(:path), its(:role_name), its(:role_id), its(:arn), its(:create_date), its(:assume_role_policy_document), its(:description), its(:tags), its(:max_session_duration), its(:permissions_boundary)
1766
+ ### its(:path), its(:role_name), its(:role_id), its(:arn), its(:create_date), its(:assume_role_policy_document), its(:description), its(:max_session_duration), its(:permissions_boundary), its(:tags)
1767
1767
  ### :unlock: Advanced use
1768
1768
 
1769
1769
  `iam_role` can use `Aws::IAM::Role` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/Role.html).
@@ -1852,7 +1852,7 @@ end
1852
1852
  ```
1853
1853
 
1854
1854
 
1855
- ### its(:path), its(:user_name), its(:user_id), its(:arn), its(:create_date), its(:password_last_used), its(:tags), its(:permissions_boundary)
1855
+ ### its(:path), its(:user_name), its(:user_id), its(:arn), its(:create_date), its(:password_last_used), its(:permissions_boundary), its(:tags)
1856
1856
  ### :unlock: Advanced use
1857
1857
 
1858
1858
  `iam_user` can use `Aws::IAM::User` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/User.html).
@@ -9,7 +9,7 @@ module Awspec
9
9
 
10
10
  types = %w(
11
11
  vpc ec2 rds security_group elb network_acl route_table subnet nat_gateway network_interface alb nlb
12
- internet_gateway
12
+ internet_gateway autoscaling_group
13
13
  )
14
14
 
15
15
  types.each do |type|
@@ -32,6 +32,7 @@ require 'awspec/generator/spec/eip'
32
32
  require 'awspec/generator/spec/rds_db_parameter_group'
33
33
  require 'awspec/generator/spec/rds_db_cluster_parameter_group'
34
34
  require 'awspec/generator/spec/codebuild'
35
+ require 'awspec/generator/spec/autoscaling_group'
35
36
 
36
37
  # Doc
37
38
  require 'awspec/generator/doc/type'
@@ -0,0 +1,52 @@
1
+ module Awspec::Generator
2
+ module Spec
3
+ class AutoscalingGroup
4
+ include Awspec::Helper::Finder
5
+ def generate_by_vpc_id(vpc_id)
6
+ describes = %w(
7
+ auto_scaling_group_name auto_scaling_group_arn min_size max_size desired_capacity
8
+ default_cooldown availability_zones health_check_type health_check_grace_period
9
+ vpc_zone_identifier termination_policies new_instances_protected_from_scale_in
10
+ )
11
+ vpc = find_vpc(vpc_id)
12
+ raise 'Not Found VPC' unless vpc
13
+ @vpc_id = vpc[:vpc_id]
14
+ @vpc_tag_name = vpc.tag_name
15
+ autoscaling_groups = select_autoscaling_group_by_vpc_id(@vpc_id)
16
+ specs = autoscaling_groups.map do |autoscaling_group|
17
+ content = ERB.new(autoscaling_group_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
18
+ end
19
+ specs.join("\n")
20
+ end
21
+
22
+ def autoscaling_group_spec_template
23
+ template = <<-'EOF'
24
+ describe autoscaling_group('<%= autoscaling_group.auto_scaling_group_name %>') do
25
+ it { should exist }
26
+ <% describes.each do |describe| %>
27
+ <%- if autoscaling_group.members.include?(describe.to_sym) && !autoscaling_group[describe.to_sym].nil? -%>
28
+ <%- if autoscaling_group[describe].is_a?(String) -%>
29
+ its(:<%= describe %>) { should eq '<%= autoscaling_group[describe] %>' }
30
+ <%- else -%>
31
+ its(:<%= describe %>) { should eq <%= autoscaling_group[describe] %> }
32
+ <%- end -%>
33
+ <%- end -%>
34
+ <% end %>
35
+ <%- unless autoscaling_group.launch_configuration_name.nil? -%>
36
+ it { should have_launch_configuration('<%= autoscaling_group.launch_configuration_name %>') }
37
+ <%- else -%>
38
+ its('launch_template.launch_template_name') { should eq '<%= autoscaling_group.launch_template.launch_template_name %>' }
39
+ <%- end -%>
40
+ <% autoscaling_group[:load_balancer_names].each do |desc| %>
41
+ it { should have_elb('<%= desc %>') }
42
+ <% end %>
43
+ <% autoscaling_group[:target_group_arns].each do |desc| %>
44
+ it { should have_alb_target_group('<%= desc.sub(/^.*targetgroup\/(.[^\/]*).*$/, '\1') %>') }
45
+ <% end %>
46
+ end
47
+ EOF
48
+ template
49
+ end
50
+ end
51
+ end
52
+ end
@@ -36,6 +36,25 @@ module Awspec::Helper
36
36
  end
37
37
  ret.single_resource(device_id)
38
38
  end
39
+
40
+ def select_autoscaling_group_by_vpc_id(vpc_id)
41
+ subnets = []
42
+ select_subnet_by_vpc_id(vpc_id).each { |subnet| subnets << subnet.subnet_id }
43
+ req = {}
44
+ selected = []
45
+ loop do
46
+ res = autoscaling_client.describe_auto_scaling_groups(req)
47
+ res.auto_scaling_groups.select do |auto_scaling_group|
48
+ vpc_zone_identifiers = auto_scaling_group.vpc_zone_identifier.split(',')
49
+ selected.push(auto_scaling_group) if vpc_zone_identifiers.any? do |vpc_zone_identifier|
50
+ subnets.include?(vpc_zone_identifier)
51
+ end
52
+ end
53
+ break if res.next_token.nil?
54
+ req[:next_token] = res.next_token
55
+ end
56
+ selected
57
+ end
39
58
  end
40
59
  end
41
60
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.12.5'
2
+ VERSION = '1.12.6'
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: 1.12.5
4
+ version: 1.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -376,6 +376,7 @@ files:
376
376
  - lib/awspec/generator/doc/type/waf_web_acl.rb
377
377
  - lib/awspec/generator/spec/acm.rb
378
378
  - lib/awspec/generator/spec/alb.rb
379
+ - lib/awspec/generator/spec/autoscaling_group.rb
379
380
  - lib/awspec/generator/spec/cloudwatch_alarm.rb
380
381
  - lib/awspec/generator/spec/cloudwatch_event.rb
381
382
  - lib/awspec/generator/spec/cloudwatch_logs.rb