awspec 0.2.3 → 0.3.0

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
  SHA1:
3
- metadata.gz: 757db940be85a0bf4a58b7b685b9872846a4415d
4
- data.tar.gz: 7024a655265da3c039ae75b8d28059e365341e7d
3
+ metadata.gz: 4badad2ffc1abf6481ed46f2ac14cfb292978238
4
+ data.tar.gz: b82dab5329c8d08599abf7efd72b646ffbf84721
5
5
  SHA512:
6
- metadata.gz: 17611435cf27ed855193720dcc961ad08f2c52ecf73f51064031970128fb244731b0486c9e8801ad7c7663d8d08bdf5f3dfdeb0da799a50805d51a0d8f1a91ca
7
- data.tar.gz: adca87391cab21aefad2260a135d1ce44438992142f177d49de636b81856ca4d4f99731d7441928f3a1fde36a3633be154b7351fd2004bc83aa6600f1a190725
6
+ metadata.gz: 0419fec2f42ff8b00b798822192e29e5356f3b548b06a7dbc010bbdf11415e2dd729f9f8ab59adcf4d0ab4c57e0e86df031adb896b3fb8693aaff6e30ab85b5e
7
+ data.tar.gz: b817f8252edb4532db87a6f8ad6a5db0de5743b8f52bbae2ce2b42c7fe89d51216540f480e89ffa2bfdaf142cad9b959e6e37ed2249767b870df51194ef1b661
data/README.md CHANGED
@@ -83,10 +83,11 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
83
83
  - [X] S3 (`s3`)
84
84
  - Route53
85
85
  - [X] Route53 Hosted Zone (`route53_hosted_zone`)
86
+ - AutoScaling
87
+ - [ ] Auto Scaling Group (`auto_scaling_group`)
86
88
 
87
89
  ### Next..
88
90
 
89
- - [ ] AutoScaling
90
91
  - ...
91
92
 
92
93
  ## TODO
@@ -28,11 +28,9 @@ EOF
28
28
  # ALIAS
29
29
  dns_name = record_set.alias_target.dns_name
30
30
  hosted_zone_id = record_set.alias_target.hosted_zone_id
31
- # rubocop:disable all
32
31
  template = <<-'EOF'
33
- it { should have_record_set('<%= record_set.name %>').alias('<%= dns_name %>', '<%= hosted_zone_id %>').ttl(<%= record_set.ttl %>) }
32
+ it { should have_record_set('<%= record_set.name %>').alias('<%= dns_name %>', '<%= hosted_zone_id %>') }
34
33
  EOF
35
- # rubocop:enable all
36
34
  return ERB.new(template, nil, '-').result(binding)
37
35
  end
38
36
  end
@@ -5,6 +5,7 @@ require 'awspec/helper/finder/security_group'
5
5
  require 'awspec/helper/finder/rds'
6
6
  require 'awspec/helper/finder/route53'
7
7
  require 'awspec/helper/finder/s3'
8
+ require 'awspec/helper/finder/auto_scaling'
8
9
 
9
10
  module Awspec::Helper
10
11
  module Finder
@@ -15,6 +16,7 @@ module Awspec::Helper
15
16
  include Awspec::Helper::Finder::Rds
16
17
  include Awspec::Helper::Finder::Route53
17
18
  include Awspec::Helper::Finder::S3
19
+ include Awspec::Helper::Finder::AutoScaling
18
20
 
19
21
  # rubocop:disable all
20
22
  def initialize(id = nil)
@@ -22,6 +24,7 @@ module Awspec::Helper
22
24
  @rds_client = Aws::RDS::Client.new
23
25
  @route53_client = Aws::Route53::Client.new
24
26
  @s3_client = Aws::S3::Client.new
27
+ @auto_scaling_client = Aws::AutoScaling::Client.new
25
28
  end
26
29
  end
27
30
  end
@@ -0,0 +1,12 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module AutoScaling
4
+ def find_auto_scaling_group(id)
5
+ res = @auto_scaling_client.describe_auto_scaling_groups({
6
+ auto_scaling_group_names: [id]
7
+ })
8
+ res[:auto_scaling_groups][0] if res[:auto_scaling_groups].count == 1
9
+ end
10
+ end
11
+ end
12
+ end
@@ -3,7 +3,7 @@ module Awspec
3
3
  module Type
4
4
  types = %w(
5
5
  base ec2 rds rds_db_parameter_group security_group
6
- vpc s3 route53_hosted_zone
6
+ vpc s3 route53_hosted_zone auto_scaling_group
7
7
  )
8
8
 
9
9
  types.each { |type| require "awspec/type/#{type}" }
@@ -0,0 +1,33 @@
1
+ module Awspec::Type
2
+ class AutoScalingGroup < Base
3
+ attr_reader :group
4
+
5
+ def initialize(id)
6
+ super
7
+ @group = find_auto_scaling_group(id)
8
+ @id = @group[:auto_scaling_group_arn] if @group
9
+ end
10
+
11
+ def has_elb?(name)
12
+ @group.load_balancer_names.find do |lb_name|
13
+ lb_name == name
14
+ end
15
+ end
16
+
17
+ def has_ec2?(id)
18
+ ec2 = find_ec2(id)
19
+ @group.instances.find do |instance|
20
+ instance.instance_id = ec2.instance_id
21
+ end if ec2
22
+ end
23
+
24
+ def method_missing(name)
25
+ describe = name.to_sym
26
+ if @group.members.include?(describe)
27
+ @group[describe]
28
+ else
29
+ super
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  module Awspec::Type
2
2
  class Rds < Base
3
- attr_reader :client, :instance
3
+ attr_reader :instance
4
4
 
5
5
  def initialize(id)
6
6
  super
@@ -1,6 +1,6 @@
1
1
  module Awspec::Type
2
2
  class S3 < Base
3
- attr_reader :s3_client, :bucket
3
+ attr_reader :bucket
4
4
 
5
5
  def initialize(id)
6
6
  super
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
@@ -140,6 +140,7 @@ files:
140
140
  - lib/awspec/generator/spec/vpc.rb
141
141
  - lib/awspec/helper.rb
142
142
  - lib/awspec/helper/finder.rb
143
+ - lib/awspec/helper/finder/auto_scaling.rb
143
144
  - lib/awspec/helper/finder/ec2.rb
144
145
  - lib/awspec/helper/finder/rds.rb
145
146
  - lib/awspec/helper/finder/route53.rb
@@ -154,6 +155,7 @@ files:
154
155
  - lib/awspec/matcher/belong_to_vpc.rb
155
156
  - lib/awspec/matcher/have_record_set.rb
156
157
  - lib/awspec/setup.rb
158
+ - lib/awspec/type/auto_scaling_group.rb
157
159
  - lib/awspec/type/base.rb
158
160
  - lib/awspec/type/ec2.rb
159
161
  - lib/awspec/type/rds.rb