awspec 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/resource_types.md +2 -0
- data/lib/awspec/generator/doc/type/auto_scaling_group.rb +1 -1
- data/lib/awspec/generator/doc/type/ebs.rb +1 -1
- data/lib/awspec/generator/doc/type/ec2.rb +1 -1
- data/lib/awspec/generator/doc/type/elb.rb +1 -1
- data/lib/awspec/generator/doc/type/iam_user.rb +2 -2
- data/lib/awspec/generator/doc/type/lambda.rb +1 -1
- data/lib/awspec/generator/doc/type/rds.rb +1 -1
- data/lib/awspec/generator/doc/type/rds_db_parameter_group.rb +0 -1
- data/lib/awspec/generator/doc/type/route53_hosted_zone.rb +1 -1
- data/lib/awspec/generator/doc/type/route_table.rb +1 -1
- data/lib/awspec/generator/doc/type/s3.rb +1 -1
- data/lib/awspec/generator/doc/type/security_group.rb +1 -1
- data/lib/awspec/generator/doc/type/subnet.rb +1 -1
- data/lib/awspec/generator/doc/type/vpc.rb +1 -1
- data/lib/awspec/generator/template.rb +1 -1
- data/lib/awspec/matcher/belong_to_db_subnet_group.rb +1 -1
- data/lib/awspec/matcher/belong_to_iam_group.rb +1 -1
- data/lib/awspec/matcher/belong_to_subnet.rb +1 -1
- data/lib/awspec/type/auto_scaling_group.rb +4 -15
- data/lib/awspec/type/base.rb +10 -1
- data/lib/awspec/type/ebs.rb +6 -16
- data/lib/awspec/type/ec2.rb +6 -15
- data/lib/awspec/type/elb.rb +7 -18
- data/lib/awspec/type/iam_user.rb +3 -14
- data/lib/awspec/type/lambda.rb +3 -14
- data/lib/awspec/type/rds.rb +10 -21
- data/lib/awspec/type/rds_db_parameter_group.rb +1 -0
- data/lib/awspec/type/route53_hosted_zone.rb +3 -12
- data/lib/awspec/type/route_table.rb +3 -14
- data/lib/awspec/type/s3.rb +2 -4
- data/lib/awspec/type/security_group.rb +7 -16
- data/lib/awspec/type/subnet.rb +3 -14
- data/lib/awspec/type/vpc.rb +4 -13
- data/lib/awspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edbd8a2286e70ffc10e86c7c47f11158b3a5df0c
|
4
|
+
data.tar.gz: 99c9ac752bfb8590c1d39e34e21e21434407fa59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e320bfea9c343abe46adace0eb3568af0d00ef304720c8fc20870f7fe3ee379ae89b46098644a97e7e549ca7a868a06ffdc206ef8a6a7ee510de8da1fd4b77c4
|
7
|
+
data.tar.gz: 3b40f6d0ccb4068bcd995d4c9b2b4198fe9f6b93aa00822a44f56e360f3c5ca785f99abec7c2011161331757e674e6afd4f44b61e022c6ad84af0c9e6a9b29e1
|
data/doc/resource_types.md
CHANGED
@@ -6,7 +6,7 @@ module Awspec::Generator
|
|
6
6
|
super
|
7
7
|
@type_name = 'RDS'
|
8
8
|
@type = Awspec::Type::Rds.new('my-rds')
|
9
|
-
@ret = @type.
|
9
|
+
@ret = @type.resource
|
10
10
|
@matchers = %w(belong_to_vpc belong_to_subnet belong_to_db_subnet_group)
|
11
11
|
@ignore_matchers = []
|
12
12
|
@describes = %w(vpc_id)
|
@@ -5,7 +5,7 @@ module Awspec::Generator
|
|
5
5
|
def initialize
|
6
6
|
super
|
7
7
|
@type = Awspec::Type::SecurityGroup.new('my-security-group-name')
|
8
|
-
@ret = @type.
|
8
|
+
@ret = @type.resource
|
9
9
|
@matchers = ['its(:inbound), its(:outbound)']
|
10
10
|
@ignore_matchers = %w(be_opened be_inbound_opened be_outbound_opened)
|
11
11
|
@describes = %w(ip_permissions_count ip_permissions_egress_count)
|
@@ -63,7 +63,7 @@ module Awspec::Generator
|
|
63
63
|
super
|
64
64
|
@type_name = '#{@type.to_camel_case}'
|
65
65
|
@type = Awspec::Type::#{@type.to_camel_case}.new('my-#{@type.to_snake_case.tr('_', '-')}')
|
66
|
-
|
66
|
+
@ret = @type.resource
|
67
67
|
@matchers = []
|
68
68
|
@ignore_matchers = []
|
69
69
|
@describes = []
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec::Matchers.define :belong_to_db_subnet_group do |db_subnet_group_name|
|
2
2
|
match do |resource|
|
3
|
-
return true if resource.
|
3
|
+
return true if resource.resource[:db_subnet_group][:db_subnet_group_name] == db_subnet_group_name
|
4
4
|
end
|
5
5
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec::Matchers.define :belong_to_iam_group do |group_id|
|
2
2
|
match do |resource|
|
3
|
-
groups = resource.select_iam_group_by_user_name(resource.
|
3
|
+
groups = resource.select_iam_group_by_user_name(resource.resource[:user_name])
|
4
4
|
groups.find do |group|
|
5
5
|
group.group_id == group_id || group.group_name == group_id
|
6
6
|
end
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :belong_to_subnet do |subnet_id|
|
|
10
10
|
|
11
11
|
# RDS
|
12
12
|
if resource.instance_of?(Awspec::Type::Rds)
|
13
|
-
subnets = resource.
|
13
|
+
subnets = resource.resource[:db_subnet_group][:subnets]
|
14
14
|
ret = subnets.find do |s|
|
15
15
|
s[:subnet_identifier] == subnet_id
|
16
16
|
end
|
@@ -1,33 +1,22 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class AutoScalingGroup < Base
|
3
|
-
attr_reader :group
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_auto_scaling_group(id)
|
6
|
+
@id = @resource[:auto_scaling_group_arn] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
def has_elb?(name)
|
12
|
-
@
|
10
|
+
@resource.load_balancer_names.find do |lb_name|
|
13
11
|
lb_name == name
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
15
|
def has_ec2?(id)
|
18
16
|
ec2 = find_ec2(id)
|
19
|
-
@
|
17
|
+
@resource.instances.find do |instance|
|
20
18
|
instance.instance_id = ec2.instance_id
|
21
19
|
end if ec2
|
22
20
|
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
21
|
end
|
33
22
|
end
|
data/lib/awspec/type/base.rb
CHANGED
@@ -4,7 +4,7 @@ require 'awspec/helper/finder'
|
|
4
4
|
module Awspec::Type
|
5
5
|
class Base
|
6
6
|
include Awspec::Helper::Finder
|
7
|
-
attr_reader :id
|
7
|
+
attr_reader :id, :resource
|
8
8
|
|
9
9
|
def initialize(id = nil)
|
10
10
|
super
|
@@ -14,5 +14,14 @@ module Awspec::Type
|
|
14
14
|
def exists?
|
15
15
|
@id
|
16
16
|
end
|
17
|
+
|
18
|
+
def method_missing(name)
|
19
|
+
describe = name.to_sym
|
20
|
+
if @resource.members.include?(describe)
|
21
|
+
@resource[describe]
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
data/lib/awspec/type/ebs.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Ebs < Base
|
3
|
-
attr_reader :volume
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_ebs(id)
|
6
|
+
@id = @resource[:volume_id] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
states = %w(
|
@@ -14,24 +12,16 @@ module Awspec::Type
|
|
14
12
|
|
15
13
|
states.each do |state|
|
16
14
|
define_method state.tr('-', '_') + '?' do
|
17
|
-
@
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def method_missing(name)
|
22
|
-
describe = name.to_sym
|
23
|
-
if @volume.members.include?(describe)
|
24
|
-
@volume[describe]
|
25
|
-
else
|
26
|
-
super
|
15
|
+
@resource[:state] == state
|
27
16
|
end
|
28
17
|
end
|
29
18
|
|
30
19
|
def attached_to?(instance_id)
|
31
20
|
instance = find_ec2(instance_id)
|
32
21
|
return false unless instance
|
33
|
-
return false unless @
|
34
|
-
@
|
22
|
+
return false unless @resource[:attachments]
|
23
|
+
@resource[:attachments][0][:instance_id] == instance[:instance_id] && \
|
24
|
+
@resource[:attachments][0][:state] == 'attached'
|
35
25
|
end
|
36
26
|
end
|
37
27
|
end
|
data/lib/awspec/type/ec2.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Ec2 < Base
|
3
|
-
attr_reader :client
|
3
|
+
attr_reader :client
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
7
|
@client = @ec2_client
|
8
|
-
@
|
9
|
-
@id = @
|
8
|
+
@resource = find_ec2(id)
|
9
|
+
@id = @resource[:instance_id] if @resource
|
10
10
|
end
|
11
11
|
|
12
12
|
states = %w(
|
@@ -16,16 +16,7 @@ module Awspec::Type
|
|
16
16
|
|
17
17
|
states.each do |state|
|
18
18
|
define_method state.tr('-', '_') + '?' do
|
19
|
-
@
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def method_missing(name)
|
24
|
-
describe = name.to_sym
|
25
|
-
if @instance.members.include?(describe)
|
26
|
-
@instance[describe]
|
27
|
-
else
|
28
|
-
super
|
19
|
+
@resource[:state][:name] == state
|
29
20
|
end
|
30
21
|
end
|
31
22
|
|
@@ -40,7 +31,7 @@ module Awspec::Type
|
|
40
31
|
end
|
41
32
|
|
42
33
|
def has_security_group?(sg_id)
|
43
|
-
sgs = @
|
34
|
+
sgs = @resource[:security_groups]
|
44
35
|
ret = sgs.find do |sg|
|
45
36
|
sg[:group_id] == sg_id || sg[:group_name] == sg_id
|
46
37
|
end
|
@@ -53,7 +44,7 @@ module Awspec::Type
|
|
53
44
|
end
|
54
45
|
|
55
46
|
def has_ebs?(volume_id)
|
56
|
-
blocks = @
|
47
|
+
blocks = @resource[:block_device_mappings]
|
57
48
|
ret = blocks.find do |block|
|
58
49
|
next false unless block[:ebs]
|
59
50
|
block[:ebs][:volume_id] == volume_id
|
data/lib/awspec/type/elb.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Elb < Base
|
3
|
-
attr_reader :lb
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_elb(id)
|
6
|
+
@id = @resource[:load_balancer_name] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
health_check_options = %w(
|
@@ -15,28 +13,19 @@ module Awspec::Type
|
|
15
13
|
|
16
14
|
health_check_options.each do |option|
|
17
15
|
define_method 'health_check_' + option do
|
18
|
-
@
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def method_missing(name)
|
23
|
-
describe = name.to_sym
|
24
|
-
if @lb.members.include?(describe)
|
25
|
-
@lb[describe]
|
26
|
-
else
|
27
|
-
super
|
16
|
+
@resource[:health_check][option]
|
28
17
|
end
|
29
18
|
end
|
30
19
|
|
31
20
|
def has_ec2?(id)
|
32
21
|
ec2 = find_ec2(id)
|
33
|
-
@
|
22
|
+
@resource.instances.find do |instance|
|
34
23
|
instance.instance_id = ec2.instance_id
|
35
24
|
end if ec2
|
36
25
|
end
|
37
26
|
|
38
27
|
def has_security_group?(sg_id)
|
39
|
-
sgs = @
|
28
|
+
sgs = @resource[:security_groups]
|
40
29
|
ret = sgs.find do |sg|
|
41
30
|
sg == sg_id
|
42
31
|
end
|
@@ -49,7 +38,7 @@ module Awspec::Type
|
|
49
38
|
end
|
50
39
|
|
51
40
|
def has_subnet?(subnet_id)
|
52
|
-
subnets = @
|
41
|
+
subnets = @resource[:subnets]
|
53
42
|
ret = subnets.find do |s|
|
54
43
|
s == subnet_id
|
55
44
|
end
|
@@ -61,7 +50,7 @@ module Awspec::Type
|
|
61
50
|
end
|
62
51
|
|
63
52
|
def has_listener?(protocol:, port:, instance_protocol:, instance_port:)
|
64
|
-
@
|
53
|
+
@resource[:listener_descriptions].find do |desc|
|
65
54
|
listener = desc.listener
|
66
55
|
listener.protocol == protocol && listener.load_balancer_port == port && \
|
67
56
|
listener.instance_protocol == instance_protocol && listener.instance_port == instance_port
|
data/lib/awspec/type/iam_user.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class IamUser < Base
|
3
|
-
attr_reader :user
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(name)
|
12
|
-
describe = name.to_sym
|
13
|
-
if @user.members.include?(describe)
|
14
|
-
@user[describe]
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
5
|
+
@resource = find_iam_user(id)
|
6
|
+
@id = @resource[:user_id] if @resource
|
18
7
|
end
|
19
8
|
|
20
9
|
def has_iam_policy?(policy_id)
|
21
|
-
policies = select_iam_policy_by_user_name(@
|
10
|
+
policies = select_iam_policy_by_user_name(@resource[:user_name])
|
22
11
|
policies.find do |policy|
|
23
12
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
24
13
|
end
|
data/lib/awspec/type/lambda.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Lambda < Base
|
3
|
-
attr_reader :function
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(name)
|
12
|
-
describe = name.to_sym
|
13
|
-
if @function.members.include?(describe)
|
14
|
-
@function[describe]
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
5
|
+
@resource = find_lambda(id)
|
6
|
+
@id = @resource[:function_arn] if @resource
|
18
7
|
end
|
19
8
|
|
20
9
|
def timeout
|
21
|
-
@
|
10
|
+
@resource[:timeout]
|
22
11
|
end
|
23
12
|
|
24
13
|
def has_event_source?(event_source_arn)
|
data/lib/awspec/type/rds.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Rds < Base
|
3
|
-
attr_reader :instance
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_rds(id)
|
6
|
+
@id = @resource[:db_instance_identifier] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
states = %w(
|
@@ -20,21 +18,12 @@ module Awspec::Type
|
|
20
18
|
|
21
19
|
states.each do |state|
|
22
20
|
define_method state.tr('-', '_') + '?' do
|
23
|
-
@
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def method_missing(name)
|
28
|
-
describe = name.to_sym
|
29
|
-
if @instance.members.include?(describe)
|
30
|
-
@instance[describe]
|
31
|
-
else
|
32
|
-
super
|
21
|
+
@resource[:db_instance_status] == state
|
33
22
|
end
|
34
23
|
end
|
35
24
|
|
36
25
|
def vpc_id
|
37
|
-
@
|
26
|
+
@resource[:db_subnet_group][:vpc_id]
|
38
27
|
end
|
39
28
|
|
40
29
|
def has_security_group?(sg_id)
|
@@ -45,14 +34,14 @@ module Awspec::Type
|
|
45
34
|
end
|
46
35
|
|
47
36
|
def has_db_parameter_group?(name)
|
48
|
-
pgs = @
|
37
|
+
pgs = @resource[:db_parameter_groups]
|
49
38
|
pgs.find do |pg|
|
50
39
|
pg[:db_parameter_group_name] == name
|
51
40
|
end
|
52
41
|
end
|
53
42
|
|
54
43
|
def has_option_group?(name)
|
55
|
-
ogs = @
|
44
|
+
ogs = @resource[:option_group_memberships]
|
56
45
|
ogs.find do |og|
|
57
46
|
og[:option_group_name] == name
|
58
47
|
end
|
@@ -61,14 +50,14 @@ module Awspec::Type
|
|
61
50
|
private
|
62
51
|
|
63
52
|
def has_vpc_security_group_id?(sg_id)
|
64
|
-
sgs = @
|
53
|
+
sgs = @resource[:vpc_security_groups]
|
65
54
|
sgs.find do |sg|
|
66
55
|
sg[:vpc_security_group_id] == sg_id
|
67
56
|
end
|
68
57
|
end
|
69
58
|
|
70
59
|
def has_vpc_security_group_name?(sg_id)
|
71
|
-
sgs = @
|
60
|
+
sgs = @resource[:vpc_security_groups]
|
72
61
|
res = @ec2_client.describe_security_groups({
|
73
62
|
filters: [{ name: 'group-name', values: [sg_id] }]
|
74
63
|
})
|
@@ -79,7 +68,7 @@ module Awspec::Type
|
|
79
68
|
end
|
80
69
|
|
81
70
|
def has_vpc_security_group_tag_name?(sg_id)
|
82
|
-
sgs = @
|
71
|
+
sgs = @resource[:vpc_security_groups]
|
83
72
|
res = @ec2_client.describe_security_groups({
|
84
73
|
filters: [{ name: 'tag:Name', values: [sg_id] }]
|
85
74
|
})
|
@@ -90,7 +79,7 @@ module Awspec::Type
|
|
90
79
|
end
|
91
80
|
|
92
81
|
def has_db_security_group_name?(sg_id)
|
93
|
-
sgs = @
|
82
|
+
sgs = @resource[:db_security_groups]
|
94
83
|
sgs.find do |sg|
|
95
84
|
sg[:db_security_group_name] == sg_id
|
96
85
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Route53HostedZone < Base
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :resource_record_sets
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
7
|
+
@resource = find_hosted_zone(id)
|
8
|
+
@id = @resource[:id] if @resource
|
9
9
|
return unless @id
|
10
10
|
res = @route53_client.list_resource_record_sets({
|
11
11
|
hosted_zone_id: @id
|
@@ -30,14 +30,5 @@ module Awspec::Type
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
def method_missing(name)
|
35
|
-
describe = name.to_sym
|
36
|
-
if @hosted_zone.members.include?(describe)
|
37
|
-
@hosted_zone[describe]
|
38
|
-
else
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
33
|
end
|
43
34
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class RouteTable < Base
|
3
|
-
attr_reader :route_table
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_route_table(id)
|
6
|
+
@id = @resource[:route_table_id] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
def has_route?(target, destination = nil)
|
12
|
-
@
|
10
|
+
@resource.routes.find do |route|
|
13
11
|
if destination
|
14
12
|
next false unless route.destination_cidr_block == destination
|
15
13
|
end
|
@@ -18,14 +16,5 @@ module Awspec::Type
|
|
18
16
|
next true if igw.internet_gateway_id == target || igw.tag_name == target
|
19
17
|
end
|
20
18
|
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
19
|
end
|
31
20
|
end
|
data/lib/awspec/type/s3.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class SecurityGroup < Base
|
3
|
-
attr_reader :client
|
3
|
+
attr_reader :client
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
7
|
@client = @ec2_client
|
8
8
|
@inbound = true
|
9
|
-
@
|
10
|
-
@id = @
|
11
|
-
end
|
12
|
-
|
13
|
-
def method_missing(name)
|
14
|
-
describe = name.to_s
|
15
|
-
if @sg.key?(describe)
|
16
|
-
@sg[describe]
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
9
|
+
@resource = find_security_group(id)
|
10
|
+
@id = @resource[:group_id] if @resource
|
20
11
|
end
|
21
12
|
|
22
13
|
def opened?(port = nil, protocol = nil, cidr = nil)
|
@@ -28,7 +19,7 @@ module Awspec::Type
|
|
28
19
|
end
|
29
20
|
|
30
21
|
def inbound_opened?(port = nil, protocol = nil, cidr = nil)
|
31
|
-
@
|
22
|
+
@resource[:ip_permissions].find do |permission|
|
32
23
|
next true unless port
|
33
24
|
next true unless permission[:from_port]
|
34
25
|
next true unless permission[:to_port]
|
@@ -52,7 +43,7 @@ module Awspec::Type
|
|
52
43
|
end
|
53
44
|
|
54
45
|
def outbound_opened?(port = nil, protocol = nil, cidr = nil)
|
55
|
-
@
|
46
|
+
@resource[:ip_permissions_egress].find do |permission|
|
56
47
|
next true unless port
|
57
48
|
next true unless permission[:from_port]
|
58
49
|
next true unless permission[:to_port]
|
@@ -86,12 +77,12 @@ module Awspec::Type
|
|
86
77
|
end
|
87
78
|
|
88
79
|
def ip_permissions_count
|
89
|
-
@
|
80
|
+
@resource[:ip_permissions].count
|
90
81
|
end
|
91
82
|
alias_method :inbound_permissions_count, :ip_permissions_count
|
92
83
|
|
93
84
|
def ip_permissions_egress_count
|
94
|
-
@
|
85
|
+
@resource[:ip_permissions_egress].count
|
95
86
|
end
|
96
87
|
alias_method :outbound_permissions_count, :ip_permissions_egress_count
|
97
88
|
end
|
data/lib/awspec/type/subnet.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Subnet < Base
|
3
|
-
attr_reader :subnet
|
4
|
-
|
5
3
|
def initialize(id)
|
6
4
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
5
|
+
@resource = find_subnet(id)
|
6
|
+
@id = @resource[:subnet_id] if @resource
|
9
7
|
end
|
10
8
|
|
11
9
|
states = %w(
|
@@ -14,16 +12,7 @@ module Awspec::Type
|
|
14
12
|
|
15
13
|
states.each do |state|
|
16
14
|
define_method state + '?' do
|
17
|
-
@
|
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
|
15
|
+
@resource[:state] == state
|
27
16
|
end
|
28
17
|
end
|
29
18
|
end
|
data/lib/awspec/type/vpc.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Vpc < Base
|
3
|
-
attr_reader :client
|
3
|
+
attr_reader :client
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
7
|
@client = @ec2_client
|
8
|
-
@
|
9
|
-
@id = @
|
8
|
+
@resource = find_vpc(id)
|
9
|
+
@id = @resource[:vpc_id] if @resource
|
10
10
|
end
|
11
11
|
|
12
12
|
states = %w(
|
@@ -15,16 +15,7 @@ module Awspec::Type
|
|
15
15
|
|
16
16
|
states.each do |state|
|
17
17
|
define_method state + '?' do
|
18
|
-
@
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def method_missing(name)
|
23
|
-
describe = name.to_s
|
24
|
-
if @vpc.key?(describe)
|
25
|
-
@vpc[describe]
|
26
|
-
else
|
27
|
-
super
|
18
|
+
@resource[:state] == state
|
28
19
|
end
|
29
20
|
end
|
30
21
|
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|