awspec 0.3.0 → 0.4.0

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: 4badad2ffc1abf6481ed46f2ac14cfb292978238
4
- data.tar.gz: b82dab5329c8d08599abf7efd72b646ffbf84721
3
+ metadata.gz: 9899a6c41db7288dc6098840b36cffe8cd9c6836
4
+ data.tar.gz: 0ff3377d77778182c0b0e4288617c61461ac749c
5
5
  SHA512:
6
- metadata.gz: 0419fec2f42ff8b00b798822192e29e5356f3b548b06a7dbc010bbdf11415e2dd729f9f8ab59adcf4d0ab4c57e0e86df031adb896b3fb8693aaff6e30ab85b5e
7
- data.tar.gz: b817f8252edb4532db87a6f8ad6a5db0de5743b8f52bbae2ce2b42c7fe89d51216540f480e89ffa2bfdaf142cad9b959e6e37ed2249767b870df51194ef1b661
6
+ metadata.gz: ef5ff136b8790b96f4a9675343bc89316eda0b2f6eb9e2cbac188c1a7432b976b2d46ff0a64f8f6ca1db2ffde508f9e2094cd509e73ae645ee743d9b91c32917
7
+ data.tar.gz: 3921163912753ffc4dc078b8a4ded4194f1332925d39b21fad7a6d29b7258610fa25881db423a0984a3d9ffb27cba6686021bfdfe27bbbd0bf2953216e189ce5
data/README.md CHANGED
@@ -75,19 +75,23 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
75
75
 
76
76
  ## Support AWS Resources
77
77
 
78
- - [X] EC2 (`ec2`)
79
- - [X] RDS (`rds`)
80
- - [X] RDS DB Parameter Group (`rds_db_parameter_group`)
81
- - [X] Security Group (`security_group`)
82
- - [X] VPC (`vpc`)
83
- - [X] S3 (`s3`)
78
+ - [x] EC2 (`ec2`)
79
+ - [x] RDS (`rds`)
80
+ - [x] RDS DB Parameter Group (`rds_db_parameter_group`)
81
+ - [x] Security Group (`security_group`)
82
+ - [x] VPC (`vpc`)
83
+ - [x] S3 (`s3`)
84
84
  - Route53
85
- - [X] Route53 Hosted Zone (`route53_hosted_zone`)
85
+ - [x] Route53 Hosted Zone (`route53_hosted_zone`)
86
86
  - AutoScaling
87
- - [ ] Auto Scaling Group (`auto_scaling_group`)
87
+ - [x] Auto Scaling Group (`auto_scaling_group`)
88
+ - [x] Subnet (`subnet`)
89
+ - [x] RouteTable (`route_table`)
88
90
 
89
91
  ### Next..
90
92
 
93
+ - [ ] EBS Volume
94
+ - [ ] IAM
91
95
  - ...
92
96
 
93
97
  ## TODO
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
2
  begin
3
3
  require 'rspec/core/rake_task'
4
+ require 'octorelease'
4
5
  rescue LoadError
5
6
  end
6
7
 
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'bundler', '~> 1.9'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rubocop'
29
+ spec.add_development_dependency 'octorelease'
29
30
  end
@@ -45,6 +45,28 @@ module Awspec::Helper
45
45
  return res[:subnets][0] if res[:subnets].count == 1
46
46
  end
47
47
 
48
+ def find_route_table(route_table_id)
49
+ res = @ec2_client.describe_route_tables({
50
+ filters: [{ name: 'route-table-id', values: [route_table_id] }]
51
+ })
52
+ return res[:route_tables][0] if res[:route_tables].count == 1
53
+ res = @ec2_client.describe_route_tables({
54
+ filters: [{ name: 'tag:Name', values: [route_table_id] }]
55
+ })
56
+ return res[:route_tables][0] if res[:route_tables].count == 1
57
+ end
58
+
59
+ def find_internet_gateway(gateway_id)
60
+ res = @ec2_client.describe_internet_gateways({
61
+ filters: [{ name: 'internet-gateway-id', values: [gateway_id] }]
62
+ })
63
+ return res[:internet_gateways][0] if res[:internet_gateways].count == 1
64
+ res = @ec2_client.describe_internet_gateways({
65
+ filters: [{ name: 'tag:Name', values: [gateway_id] }]
66
+ })
67
+ return res[:internet_gateways][0] if res[:internet_gateways].count == 1
68
+ end
69
+
48
70
  def find_security_group(sg_id)
49
71
  res = @ec2_client.describe_security_groups({
50
72
  filters: [{ name: 'group-id', values: [sg_id] }]
@@ -3,7 +3,8 @@ 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 auto_scaling_group
6
+ vpc s3 route53_hosted_zone auto_scaling_group subnet
7
+ route_table
7
8
  )
8
9
 
9
10
  types.each { |type| require "awspec/type/#{type}" }
@@ -10,3 +10,6 @@ require 'awspec/matcher/be_opened'
10
10
 
11
11
  # Route53
12
12
  require 'awspec/matcher/have_record_set'
13
+
14
+ # RouteTable
15
+ require 'awspec/matcher/have_route'
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :have_route do |target|
2
+ match do |route_table|
3
+ route_table.has_route?(target, @destination)
4
+ end
5
+
6
+ chain :destination do |destination|
7
+ @destination = destination
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ module Awspec::Type
2
+ class RouteTable < Base
3
+ attr_reader :route_table
4
+
5
+ def initialize(id)
6
+ super
7
+ @route_table = find_route_table(id)
8
+ @id = @route_table[:route_table_id] if @route_table
9
+ end
10
+
11
+ def has_route?(target, destination = nil)
12
+ @route_table.routes.find do |route|
13
+ if destination
14
+ next false unless route.destination_cidr_block == destination
15
+ end
16
+ next true if route.gateway_id == target
17
+ igw = find_internet_gateway(target)
18
+ next true if igw.internet_gateway_id == target || igw.tag_name == target
19
+ end
20
+ end
21
+
22
+ def method_missing(name)
23
+ describe = name.to_sym
24
+ if @route_table.members.include?(describe)
25
+ @route_table[describe]
26
+ else
27
+ super
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module Awspec::Type
2
+ class Subnet < Base
3
+ attr_reader :subnet
4
+
5
+ def initialize(id)
6
+ super
7
+ @subnet = find_subnet(id)
8
+ @id = @subnet[:subnet_id] if @subnet
9
+ end
10
+
11
+ states = %w(
12
+ available pending
13
+ )
14
+
15
+ states.each do |state|
16
+ define_method state + '?' do
17
+ @subnet[:state] == state
18
+ end
19
+ end
20
+
21
+ def method_missing(name)
22
+ describe = name.to_sym
23
+ if @subnet.members.include?(describe)
24
+ @subnet[describe]
25
+ else
26
+ super
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: octorelease
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: RSpec tests for your AWS resources.
112
126
  email:
113
127
  - k1lowxb@gmail.com
@@ -154,6 +168,7 @@ files:
154
168
  - lib/awspec/matcher/belong_to_subnet.rb
155
169
  - lib/awspec/matcher/belong_to_vpc.rb
156
170
  - lib/awspec/matcher/have_record_set.rb
171
+ - lib/awspec/matcher/have_route.rb
157
172
  - lib/awspec/setup.rb
158
173
  - lib/awspec/type/auto_scaling_group.rb
159
174
  - lib/awspec/type/base.rb
@@ -161,8 +176,10 @@ files:
161
176
  - lib/awspec/type/rds.rb
162
177
  - lib/awspec/type/rds_db_parameter_group.rb
163
178
  - lib/awspec/type/route53_hosted_zone.rb
179
+ - lib/awspec/type/route_table.rb
164
180
  - lib/awspec/type/s3.rb
165
181
  - lib/awspec/type/security_group.rb
182
+ - lib/awspec/type/subnet.rb
166
183
  - lib/awspec/type/vpc.rb
167
184
  - lib/awspec/version.rb
168
185
  homepage: https://github.com/k1LoW/awspec