awspec 0.3.0 → 0.4.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 +4 -4
- data/README.md +12 -8
- data/Rakefile +1 -0
- data/awspec.gemspec +1 -0
- data/lib/awspec/helper/finder/ec2.rb +22 -0
- data/lib/awspec/helper/type.rb +2 -1
- data/lib/awspec/matcher.rb +3 -0
- data/lib/awspec/matcher/have_route.rb +9 -0
- data/lib/awspec/type/route_table.rb +31 -0
- data/lib/awspec/type/subnet.rb +30 -0
- data/lib/awspec/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9899a6c41db7288dc6098840b36cffe8cd9c6836
|
4
|
+
data.tar.gz: 0ff3377d77778182c0b0e4288617c61461ac749c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
- [
|
79
|
-
- [
|
80
|
-
- [
|
81
|
-
- [
|
82
|
-
- [
|
83
|
-
- [
|
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
|
-
- [
|
85
|
+
- [x] Route53 Hosted Zone (`route53_hosted_zone`)
|
86
86
|
- AutoScaling
|
87
|
-
- [
|
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
data/awspec.gemspec
CHANGED
@@ -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] }]
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -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}" }
|
data/lib/awspec/matcher.rb
CHANGED
@@ -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
|
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: 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-
|
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
|