awspec 0.25.3 → 0.26.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/awspec.gemspec +1 -0
- data/doc/_resource_types/s3_bucket.md +10 -0
- data/doc/resource_types.md +32 -21
- data/lib/awspec.rb +1 -0
- data/lib/awspec/generator/doc/type/autoscaling_group.rb +1 -1
- data/lib/awspec/generator/doc/type/base.rb +5 -2
- data/lib/awspec/generator/doc/type/cloudwatch_alarm.rb +1 -1
- data/lib/awspec/generator/doc/type/directconnect_virtual_interface.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/elasticache.rb +1 -1
- data/lib/awspec/generator/doc/type/elasticache_cache_parameter_group.rb +1 -1
- data/lib/awspec/generator/doc/type/elb.rb +1 -1
- data/lib/awspec/generator/doc/type/iam_group.rb +1 -1
- data/lib/awspec/generator/doc/type/iam_policy.rb +1 -1
- data/lib/awspec/generator/doc/type/iam_role.rb +1 -1
- data/lib/awspec/generator/doc/type/iam_user.rb +1 -1
- data/lib/awspec/generator/doc/type/lambda.rb +1 -1
- data/lib/awspec/generator/doc/type/network_acl.rb +1 -1
- data/lib/awspec/generator/doc/type/rds.rb +1 -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_bucket.rb +1 -1
- data/lib/awspec/generator/doc/type/security_group.rb +1 -1
- data/lib/awspec/generator/doc/type/ses_identity.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/be_allowed.rb +2 -2
- data/lib/awspec/matcher/be_allowed_action.rb +2 -2
- data/lib/awspec/matcher/be_denied.rb +2 -2
- data/lib/awspec/matcher/belong_to_cache_subnet_group.rb +2 -2
- data/lib/awspec/matcher/belong_to_db_subnet_group.rb +2 -2
- data/lib/awspec/matcher/belong_to_iam_group.rb +2 -2
- data/lib/awspec/matcher/belong_to_metric.rb +3 -3
- data/lib/awspec/matcher/belong_to_replication_group.rb +2 -2
- data/lib/awspec/matcher/belong_to_subnet.rb +12 -12
- data/lib/awspec/matcher/belong_to_vpc.rb +4 -4
- data/lib/awspec/resource_reader.rb +48 -0
- data/lib/awspec/type/autoscaling_group.rb +4 -4
- data/lib/awspec/type/base.rb +8 -4
- data/lib/awspec/type/cloudwatch_alarm.rb +5 -5
- data/lib/awspec/type/directconnect_virtual_interface.rb +3 -3
- data/lib/awspec/type/ebs.rb +6 -6
- data/lib/awspec/type/ec2.rb +5 -5
- data/lib/awspec/type/elasticache.rb +5 -5
- data/lib/awspec/type/elasticache_cache_parameter_group.rb +1 -1
- data/lib/awspec/type/elb.rb +7 -7
- data/lib/awspec/type/iam_group.rb +3 -3
- data/lib/awspec/type/iam_policy.rb +3 -3
- data/lib/awspec/type/iam_role.rb +3 -3
- data/lib/awspec/type/iam_user.rb +3 -3
- data/lib/awspec/type/lambda.rb +3 -3
- data/lib/awspec/type/network_acl.rb +6 -6
- data/lib/awspec/type/rds.rb +10 -10
- data/lib/awspec/type/rds_db_parameter_group.rb +1 -1
- data/lib/awspec/type/route53_hosted_zone.rb +4 -4
- data/lib/awspec/type/route_table.rb +4 -4
- data/lib/awspec/type/s3_bucket.rb +6 -2
- data/lib/awspec/type/security_group.rb +8 -8
- data/lib/awspec/type/ses_identity.rb +2 -2
- data/lib/awspec/type/subnet.rb +3 -3
- data/lib/awspec/type/vpc.rb +3 -3
- data/lib/awspec/version.rb +1 -1
- metadata +17 -2
@@ -2,8 +2,8 @@ module Awspec::Type
|
|
2
2
|
class IamGroup < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_iam_group(id)
|
6
|
+
@id = @resource_via_client[:group_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_iam_user?(user_id)
|
@@ -17,7 +17,7 @@ module Awspec::Type
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def has_iam_policy?(policy_id)
|
20
|
-
policies = select_iam_policy_by_group_name(@
|
20
|
+
policies = select_iam_policy_by_group_name(@resource_via_client[:group_name])
|
21
21
|
policies.find do |policy|
|
22
22
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
23
23
|
end
|
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class IamPolicy < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_iam_policy(id)
|
6
|
+
@id = @resource_via_client[:policy_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def attachable?
|
10
|
-
@
|
10
|
+
@resource_via_client.is_attachable
|
11
11
|
end
|
12
12
|
|
13
13
|
def attached_to_user?(user_id = nil)
|
data/lib/awspec/type/iam_role.rb
CHANGED
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class IamRole < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_iam_role(id)
|
6
|
+
@id = @resource_via_client[:role_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_iam_policy?(policy_id)
|
10
|
-
policies = select_iam_policy_by_role_name(@
|
10
|
+
policies = select_iam_policy_by_role_name(@resource_via_client[:role_name])
|
11
11
|
policies.find do |policy|
|
12
12
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
13
13
|
end
|
data/lib/awspec/type/iam_user.rb
CHANGED
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class IamUser < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_iam_user(id)
|
6
|
+
@id = @resource_via_client[:user_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_iam_policy?(policy_id)
|
10
|
-
policies = select_iam_policy_by_user_name(@
|
10
|
+
policies = select_iam_policy_by_user_name(@resource_via_client[:user_name])
|
11
11
|
policies.find do |policy|
|
12
12
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
13
13
|
end
|
data/lib/awspec/type/lambda.rb
CHANGED
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class Lambda < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_lambda(id)
|
6
|
+
@id = @resource_via_client[:function_arn] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def timeout
|
10
|
-
@
|
10
|
+
@resource_via_client[:timeout]
|
11
11
|
end
|
12
12
|
|
13
13
|
def has_event_source?(event_source_arn)
|
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class NetworkAcl < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_network_acl(id)
|
6
|
+
@id = @resource_via_client[:network_acl_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_subnet?(subnet_id)
|
10
|
-
@
|
10
|
+
@resource_via_client.associations.find do |a|
|
11
11
|
next true if a.subnet_id == subnet_id
|
12
12
|
subnet = find_subnet(subnet_id)
|
13
13
|
next false unless subnet
|
@@ -36,13 +36,13 @@ module Awspec::Type
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def inbound_entries_count
|
39
|
-
@
|
39
|
+
@resource_via_client[:entries].count do |entry|
|
40
40
|
entry.egress == false
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def outbound_entries_count
|
45
|
-
@
|
45
|
+
@resource_via_client[:entries].count do |entry|
|
46
46
|
entry.egress == true
|
47
47
|
end
|
48
48
|
end
|
@@ -68,7 +68,7 @@ module Awspec::Type
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def entry?(rule_action, port = nil, protocol = nil, cidr = nil, rule_number = nil)
|
71
|
-
@
|
71
|
+
@resource_via_client[:entries].find do |entry|
|
72
72
|
# egress rule_action
|
73
73
|
next false if entry.egress != @egress
|
74
74
|
next false if entry.rule_action != rule_action
|
data/lib/awspec/type/rds.rb
CHANGED
@@ -2,8 +2,8 @@ module Awspec::Type
|
|
2
2
|
class Rds < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_rds(id)
|
6
|
+
@id = @resource_via_client[:db_instance_identifier] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
STATES = %w(
|
@@ -18,12 +18,12 @@ module Awspec::Type
|
|
18
18
|
|
19
19
|
STATES.each do |state|
|
20
20
|
define_method state.tr('-', '_') + '?' do
|
21
|
-
@
|
21
|
+
@resource_via_client[:db_instance_status] == state
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def vpc_id
|
26
|
-
@
|
26
|
+
@resource_via_client[:db_subnet_group][:vpc_id]
|
27
27
|
end
|
28
28
|
|
29
29
|
def has_security_group?(sg_id)
|
@@ -34,14 +34,14 @@ module Awspec::Type
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def has_db_parameter_group?(name)
|
37
|
-
pgs = @
|
37
|
+
pgs = @resource_via_client[:db_parameter_groups]
|
38
38
|
pgs.find do |pg|
|
39
39
|
pg[:db_parameter_group_name] == name
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def has_option_group?(name)
|
44
|
-
ogs = @
|
44
|
+
ogs = @resource_via_client[:option_group_memberships]
|
45
45
|
ogs.find do |og|
|
46
46
|
og[:option_group_name] == name
|
47
47
|
end
|
@@ -50,14 +50,14 @@ module Awspec::Type
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def has_vpc_security_group_id?(sg_id)
|
53
|
-
sgs = @
|
53
|
+
sgs = @resource_via_client[:vpc_security_groups]
|
54
54
|
sgs.find do |sg|
|
55
55
|
sg[:vpc_security_group_id] == sg_id
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
def has_vpc_security_group_name?(sg_id)
|
60
|
-
sgs = @
|
60
|
+
sgs = @resource_via_client[:vpc_security_groups]
|
61
61
|
res = @ec2_client.describe_security_groups({
|
62
62
|
filters: [{ name: 'group-name', values: [sg_id] }]
|
63
63
|
})
|
@@ -68,7 +68,7 @@ module Awspec::Type
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def has_vpc_security_group_tag_name?(sg_id)
|
71
|
-
sgs = @
|
71
|
+
sgs = @resource_via_client[:vpc_security_groups]
|
72
72
|
res = @ec2_client.describe_security_groups({
|
73
73
|
filters: [{ name: 'tag:Name', values: [sg_id] }]
|
74
74
|
})
|
@@ -79,7 +79,7 @@ module Awspec::Type
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def has_db_security_group_name?(sg_id)
|
82
|
-
sgs = @
|
82
|
+
sgs = @resource_via_client[:db_security_groups]
|
83
83
|
sgs.find do |sg|
|
84
84
|
sg[:db_security_group_name] == sg_id
|
85
85
|
end
|
@@ -4,15 +4,15 @@ module Awspec::Type
|
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
|
-
@
|
8
|
-
@id = @
|
7
|
+
@resource_via_client = find_hosted_zone(id)
|
8
|
+
@id = @resource_via_client[:id] if @resource_via_client
|
9
9
|
return unless @id
|
10
|
-
@
|
10
|
+
@resource_via_client_record_sets = select_record_sets_by_hosted_zone_id(@id)
|
11
11
|
end
|
12
12
|
|
13
13
|
def has_record_set?(name, type, value, options = {})
|
14
14
|
name.gsub!(/\*/, '\\\052') # wildcard support
|
15
|
-
ret = @
|
15
|
+
ret = @resource_via_client_record_sets.find do |record_set|
|
16
16
|
next if record_set.type != type.upcase
|
17
17
|
options[:ttl] = record_set.ttl unless options[:ttl]
|
18
18
|
if !record_set.resource_records.empty?
|
@@ -2,12 +2,12 @@ module Awspec::Type
|
|
2
2
|
class RouteTable < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_route_table(id)
|
6
|
+
@id = @resource_via_client[:route_table_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_route?(destination, gateway_id = nil, instance_id = nil, vpc_peering_connection_id = nil)
|
10
|
-
@
|
10
|
+
@resource_via_client.routes.find do |route|
|
11
11
|
if destination
|
12
12
|
next false unless route.destination_cidr_block == destination
|
13
13
|
end
|
@@ -20,7 +20,7 @@ module Awspec::Type
|
|
20
20
|
def has_subnet?(subnet_id)
|
21
21
|
subnet = find_subnet(subnet_id)
|
22
22
|
return false unless subnet
|
23
|
-
@
|
23
|
+
@resource_via_client.associations.find do |a|
|
24
24
|
a[:subnet_id] == subnet[:subnet_id]
|
25
25
|
end
|
26
26
|
end
|
@@ -2,8 +2,8 @@ module Awspec::Type
|
|
2
2
|
class S3Bucket < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = id if @
|
5
|
+
@resource_via_client = find_bucket(id)
|
6
|
+
@id = id if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_object?(key)
|
@@ -58,6 +58,10 @@ module Awspec::Type
|
|
58
58
|
bp ? (bp.policy.read == policy.gsub(/(\n|\r|\r\n|\s|\t)/, '')) : false
|
59
59
|
end
|
60
60
|
|
61
|
+
def hogehoge
|
62
|
+
@hogehoge ||= Awspec::ResourceReader.new(Aws::S3::Bucket.new(@id))
|
63
|
+
end
|
64
|
+
|
61
65
|
private
|
62
66
|
|
63
67
|
def cors_rules
|
@@ -6,8 +6,8 @@ module Awspec::Type
|
|
6
6
|
super
|
7
7
|
@client = @ec2_client
|
8
8
|
@inbound = true
|
9
|
-
@
|
10
|
-
@id = @
|
9
|
+
@resource_via_client = find_security_group(id)
|
10
|
+
@id = @resource_via_client[:group_id] if @resource_via_client
|
11
11
|
end
|
12
12
|
|
13
13
|
def opened?(port = nil, protocol = nil, cidr = nil)
|
@@ -19,7 +19,7 @@ module Awspec::Type
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def inbound_opened?(port = nil, protocol = nil, cidr = nil)
|
22
|
-
@
|
22
|
+
@resource_via_client[:ip_permissions].find do |permission|
|
23
23
|
next true unless port
|
24
24
|
next true unless permission[:from_port]
|
25
25
|
next true unless permission[:to_port]
|
@@ -43,7 +43,7 @@ module Awspec::Type
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def outbound_opened?(port = nil, protocol = nil, cidr = nil)
|
46
|
-
@
|
46
|
+
@resource_via_client[:ip_permissions_egress].find do |permission|
|
47
47
|
next true unless port
|
48
48
|
next true unless permission[:from_port]
|
49
49
|
next true unless permission[:to_port]
|
@@ -77,23 +77,23 @@ module Awspec::Type
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def ip_permissions_count
|
80
|
-
@
|
80
|
+
@resource_via_client[:ip_permissions].count
|
81
81
|
end
|
82
82
|
alias_method :inbound_permissions_count, :ip_permissions_count
|
83
83
|
|
84
84
|
def ip_permissions_egress_count
|
85
|
-
@
|
85
|
+
@resource_via_client[:ip_permissions_egress].count
|
86
86
|
end
|
87
87
|
alias_method :outbound_permissions_count, :ip_permissions_egress_count
|
88
88
|
|
89
89
|
def inbound_rule_count
|
90
|
-
@
|
90
|
+
@resource_via_client[:ip_permissions].reduce(0) do |sum, permission|
|
91
91
|
sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
def outbound_rule_count
|
96
|
-
@
|
96
|
+
@resource_via_client[:ip_permissions_egress].reduce(0) do |sum, permission|
|
97
97
|
sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
|
98
98
|
end
|
99
99
|
end
|
@@ -2,8 +2,8 @@ module Awspec::Type
|
|
2
2
|
class SesIdentity < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_ses_identity(id)
|
6
|
+
@id = @resource_via_client if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_identity_policy?(name)
|
data/lib/awspec/type/subnet.rb
CHANGED
@@ -2,8 +2,8 @@ module Awspec::Type
|
|
2
2
|
class Subnet < Base
|
3
3
|
def initialize(id)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
@id = @
|
5
|
+
@resource_via_client = find_subnet(id)
|
6
|
+
@id = @resource_via_client[:subnet_id] if @resource_via_client
|
7
7
|
end
|
8
8
|
|
9
9
|
STATES = %w(
|
@@ -12,7 +12,7 @@ module Awspec::Type
|
|
12
12
|
|
13
13
|
STATES.each do |state|
|
14
14
|
define_method state + '?' do
|
15
|
-
@
|
15
|
+
@resource_via_client[:state] == state
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/awspec/type/vpc.rb
CHANGED
@@ -5,8 +5,8 @@ module Awspec::Type
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
7
|
@client = @ec2_client
|
8
|
-
@
|
9
|
-
@id = @
|
8
|
+
@resource_via_client = find_vpc(id)
|
9
|
+
@id = @resource_via_client[:vpc_id] if @resource_via_client
|
10
10
|
end
|
11
11
|
|
12
12
|
STATES = %w(
|
@@ -15,7 +15,7 @@ module Awspec::Type
|
|
15
15
|
|
16
16
|
STATES.each do |state|
|
17
17
|
define_method state + '?' do
|
18
|
-
@
|
18
|
+
@resource_via_client[:state] == state
|
19
19
|
end
|
20
20
|
end
|
21
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.
|
4
|
+
version: 0.26.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-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: pry
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: RSpec tests for your AWS resources.
|
168
182
|
email:
|
169
183
|
- k1lowxb@gmail.com
|
@@ -290,6 +304,7 @@ files:
|
|
290
304
|
- lib/awspec/matcher/belong_to_vpc.rb
|
291
305
|
- lib/awspec/matcher/have_record_set.rb
|
292
306
|
- lib/awspec/matcher/have_route.rb
|
307
|
+
- lib/awspec/resource_reader.rb
|
293
308
|
- lib/awspec/setup.rb
|
294
309
|
- lib/awspec/stub.rb
|
295
310
|
- lib/awspec/stub/autoscaling_group.rb
|