awspec 0.26.2 → 0.27.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/Rakefile +13 -2
- data/doc/_resource_types/ebs.md +18 -0
- data/doc/_resource_types/ec2.md +18 -0
- data/doc/_resource_types/network_acl.md +18 -0
- data/doc/_resource_types/rds.md +18 -0
- data/doc/_resource_types/route_table.md +18 -0
- data/doc/_resource_types/security_group.md +18 -0
- data/doc/_resource_types/subnet.md +18 -0
- data/doc/_resource_types/vpc.md +18 -0
- data/doc/resource_types.md +152 -0
- data/lib/awspec/helper/finder.rb +19 -15
- data/lib/awspec/helper/finder/autoscaling.rb +3 -3
- data/lib/awspec/helper/finder/cloudwatch.rb +5 -5
- data/lib/awspec/helper/finder/directconnect.rb +2 -2
- data/lib/awspec/helper/finder/ebs.rb +7 -7
- data/lib/awspec/helper/finder/ec2.rb +46 -46
- data/lib/awspec/helper/finder/elasticache.rb +6 -6
- data/lib/awspec/helper/finder/elb.rb +4 -4
- data/lib/awspec/helper/finder/iam.rb +16 -16
- data/lib/awspec/helper/finder/lambda.rb +4 -4
- data/lib/awspec/helper/finder/rds.rb +4 -4
- data/lib/awspec/helper/finder/route53.rb +4 -4
- data/lib/awspec/helper/finder/s3.rb +6 -6
- data/lib/awspec/helper/finder/security_group.rb +12 -12
- data/lib/awspec/helper/finder/ses.rb +1 -1
- data/lib/awspec/helper/finder/vpc.rb +49 -49
- data/lib/awspec/resource_reader.rb +5 -5
- data/lib/awspec/type/base.rb +6 -1
- data/lib/awspec/type/ebs.rb +2 -0
- data/lib/awspec/type/ec2.rb +2 -3
- data/lib/awspec/type/elasticache_cache_parameter_group.rb +3 -5
- data/lib/awspec/type/network_acl.rb +2 -0
- data/lib/awspec/type/rds.rb +8 -6
- data/lib/awspec/type/rds_db_parameter_group.rb +3 -5
- data/lib/awspec/type/route53_hosted_zone.rb +0 -2
- data/lib/awspec/type/route_table.rb +2 -0
- data/lib/awspec/type/s3_bucket.rb +6 -8
- data/lib/awspec/type/security_group.rb +1 -2
- data/lib/awspec/type/ses_identity.rb +15 -15
- data/lib/awspec/type/subnet.rb +2 -0
- data/lib/awspec/type/vpc.rb +1 -2
- data/lib/awspec/version.rb +1 -1
- metadata +2 -2
@@ -2,27 +2,27 @@ module Awspec::Helper
|
|
2
2
|
module Finder
|
3
3
|
module SecurityGroup
|
4
4
|
def find_security_group(id)
|
5
|
-
res =
|
6
|
-
|
7
|
-
|
5
|
+
res = ec2_client.describe_security_groups({
|
6
|
+
filters: [{ name: 'group-id', values: [id] }]
|
7
|
+
})
|
8
8
|
|
9
9
|
return res[:security_groups].first if res[:security_groups].count == 1
|
10
|
-
res =
|
11
|
-
|
12
|
-
|
10
|
+
res = ec2_client.describe_security_groups({
|
11
|
+
filters: [{ name: 'group-name', values: [id] }]
|
12
|
+
})
|
13
13
|
|
14
14
|
return res[:security_groups].first if res[:security_groups].count == 1
|
15
|
-
res =
|
16
|
-
|
17
|
-
|
15
|
+
res = ec2_client.describe_security_groups({
|
16
|
+
filters: [{ name: 'tag:Name', values: [id] }]
|
17
|
+
})
|
18
18
|
|
19
19
|
return res[:security_groups].first if res[:security_groups].count == 1
|
20
20
|
end
|
21
21
|
|
22
22
|
def select_security_group_by_vpc_id(vpc_id)
|
23
|
-
res =
|
24
|
-
|
25
|
-
|
23
|
+
res = ec2_client.describe_security_groups({
|
24
|
+
filters: [{ name: 'vpc-id', values: [vpc_id] }]
|
25
|
+
})
|
26
26
|
res[:security_groups]
|
27
27
|
end
|
28
28
|
end
|
@@ -2,88 +2,88 @@ module Awspec::Helper
|
|
2
2
|
module Finder
|
3
3
|
module Vpc
|
4
4
|
def find_vpc(id)
|
5
|
-
res =
|
6
|
-
|
7
|
-
|
5
|
+
res = ec2_client.describe_vpcs({
|
6
|
+
filters: [{ name: 'vpc-id', values: [id] }]
|
7
|
+
})
|
8
8
|
return res[:vpcs].first if res[:vpcs].count == 1
|
9
|
-
res =
|
10
|
-
|
11
|
-
|
9
|
+
res = ec2_client.describe_vpcs({
|
10
|
+
filters: [{ name: 'tag:Name', values: [id] }]
|
11
|
+
})
|
12
12
|
return res[:vpcs].first if res[:vpcs].count == 1
|
13
13
|
end
|
14
14
|
|
15
15
|
def find_route_table(route_table_id)
|
16
|
-
res =
|
17
|
-
|
18
|
-
|
16
|
+
res = ec2_client.describe_route_tables({
|
17
|
+
filters: [{ name: 'route-table-id', values: [route_table_id] }]
|
18
|
+
})
|
19
19
|
return res[:route_tables].first if res[:route_tables].count == 1
|
20
|
-
res =
|
21
|
-
|
22
|
-
|
20
|
+
res = ec2_client.describe_route_tables({
|
21
|
+
filters: [{ name: 'tag:Name', values: [route_table_id] }]
|
22
|
+
})
|
23
23
|
return res[:route_tables].first if res[:route_tables].count == 1
|
24
24
|
end
|
25
25
|
|
26
26
|
def find_network_acl(id)
|
27
|
-
res =
|
28
|
-
|
29
|
-
|
27
|
+
res = ec2_client.describe_network_acls({
|
28
|
+
filters: [{ name: 'network-acl-id', values: [id] }]
|
29
|
+
})
|
30
30
|
return res[:network_acls].first if res[:network_acls].count == 1
|
31
|
-
res =
|
32
|
-
|
33
|
-
|
31
|
+
res = ec2_client.describe_network_acls({
|
32
|
+
filters: [{ name: 'tag:Name', values: [id] }]
|
33
|
+
})
|
34
34
|
return res[:network_acls].first if res[:network_acls].count == 1
|
35
35
|
end
|
36
36
|
|
37
37
|
def select_route_table_by_vpc_id(vpc_id)
|
38
|
-
res =
|
39
|
-
|
40
|
-
|
38
|
+
res = ec2_client.describe_route_tables({
|
39
|
+
filters: [{ name: 'vpc-id', values: [vpc_id] }]
|
40
|
+
})
|
41
41
|
res[:route_tables]
|
42
42
|
end
|
43
43
|
|
44
44
|
def select_network_acl_by_vpc_id(vpc_id)
|
45
|
-
res =
|
46
|
-
|
47
|
-
|
45
|
+
res = ec2_client.describe_network_acls({
|
46
|
+
filters: [{ name: 'vpc-id', values: [vpc_id] }]
|
47
|
+
})
|
48
48
|
res[:network_acls]
|
49
49
|
end
|
50
50
|
|
51
51
|
def find_subnet(subnet_id)
|
52
|
-
res =
|
53
|
-
|
54
|
-
|
52
|
+
res = ec2_client.describe_subnets({
|
53
|
+
filters: [{ name: 'subnet-id', values: [subnet_id] }]
|
54
|
+
})
|
55
55
|
return res[:subnets].first if res[:subnets].count == 1
|
56
|
-
res =
|
57
|
-
|
58
|
-
|
56
|
+
res = ec2_client.describe_subnets({
|
57
|
+
filters: [{ name: 'tag:Name', values: [subnet_id] }]
|
58
|
+
})
|
59
59
|
return res[:subnets].first if res[:subnets].count == 1
|
60
60
|
end
|
61
61
|
|
62
62
|
def select_subnet_by_vpc_id(vpc_id)
|
63
|
-
res =
|
64
|
-
|
65
|
-
|
63
|
+
res = ec2_client.describe_subnets({
|
64
|
+
filters: [{ name: 'vpc-id', values: [vpc_id] }]
|
65
|
+
})
|
66
66
|
res[:subnets]
|
67
67
|
end
|
68
68
|
|
69
69
|
def find_vpc_peering_connection(vpc_peering_connection_id)
|
70
|
-
res =
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
res = ec2_client.describe_vpc_peering_connections({
|
71
|
+
filters: [
|
72
|
+
{
|
73
|
+
name: 'vpc-peering-connection-id',
|
74
|
+
values: [vpc_peering_connection_id]
|
75
|
+
}
|
76
|
+
]
|
77
|
+
})
|
78
78
|
return res[:vpc_peering_connections].first if res[:vpc_peering_connections].count == 1
|
79
|
-
res =
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
res = ec2_client.describe_vpc_peering_connections({
|
80
|
+
filters: [
|
81
|
+
{
|
82
|
+
name: 'tag:Name',
|
83
|
+
values: [vpc_peering_connection_id]
|
84
|
+
}
|
85
|
+
]
|
86
|
+
})
|
87
87
|
return res[:vpc_peering_connections].first if res[:vpc_peering_connections].count == 1
|
88
88
|
end
|
89
89
|
end
|
@@ -21,12 +21,12 @@ module Awspec
|
|
21
21
|
private
|
22
22
|
|
23
23
|
BLACK_LIST_RE = /
|
24
|
-
create|
|
25
|
-
delete|
|
26
24
|
clear|
|
27
|
-
put|
|
28
|
-
|
29
|
-
|
25
|
+
create|delete|put|update|add|
|
26
|
+
attach|detach|
|
27
|
+
reboot|start|stop|
|
28
|
+
modify|reset|replace
|
29
|
+
authorize|revoke
|
30
30
|
/ix
|
31
31
|
|
32
32
|
def match_black_list?(name)
|
data/lib/awspec/type/base.rb
CHANGED
@@ -11,7 +11,6 @@ module Awspec::Type
|
|
11
11
|
|
12
12
|
def initialize(id = nil)
|
13
13
|
@display_name = id
|
14
|
-
super
|
15
14
|
@id = nil
|
16
15
|
end
|
17
16
|
|
@@ -28,6 +27,12 @@ module Awspec::Type
|
|
28
27
|
@id
|
29
28
|
end
|
30
29
|
|
30
|
+
def self.aws_resource(resource)
|
31
|
+
define_method :resource do
|
32
|
+
@resource ||= Awspec::ResourceReader.new(resource.new(@id))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
31
36
|
def method_missing(name)
|
32
37
|
describe = name.to_sym
|
33
38
|
if @resource_via_client.members.include?(describe)
|
data/lib/awspec/type/ebs.rb
CHANGED
data/lib/awspec/type/ec2.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Ec2 < Base
|
3
|
-
|
3
|
+
aws_resource Aws::EC2::Instance
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
|
-
@client = @ec2_client
|
8
7
|
@resource_via_client = find_ec2(id)
|
9
8
|
@id = @resource_via_client[:instance_id] if @resource_via_client
|
10
9
|
end
|
@@ -30,7 +29,7 @@ module Awspec::Type
|
|
30
29
|
filters: [{ name: 'instance-id', values: [@id] }]
|
31
30
|
}
|
32
31
|
option[:public_ips] = [ip_address] if ip_address
|
33
|
-
ret =
|
32
|
+
ret = ec2_client.describe_addresses(option)
|
34
33
|
return ret[:addresses].count == 1 if ip_address
|
35
34
|
return ret[:addresses].count > 0 unless ip_address
|
36
35
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class ElasticacheCacheParameterGroup < Base
|
3
|
-
attr_reader :parameters
|
4
|
-
|
5
3
|
def initialize(name)
|
6
4
|
super
|
7
5
|
@parameters = {}
|
8
|
-
res =
|
9
|
-
|
10
|
-
|
6
|
+
res = elasticache_client.describe_cache_parameters({
|
7
|
+
cache_parameter_group_name: name
|
8
|
+
})
|
11
9
|
|
12
10
|
loop do
|
13
11
|
res.parameters.each do |param|
|
data/lib/awspec/type/rds.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Rds < Base
|
3
|
+
aws_resource Aws::RDS::DBInstance
|
4
|
+
|
3
5
|
def initialize(id)
|
4
6
|
super
|
5
7
|
@resource_via_client = find_rds(id)
|
@@ -58,9 +60,9 @@ module Awspec::Type
|
|
58
60
|
|
59
61
|
def has_vpc_security_group_name?(sg_id)
|
60
62
|
sgs = @resource_via_client[:vpc_security_groups]
|
61
|
-
res =
|
62
|
-
|
63
|
-
|
63
|
+
res = ec2_client.describe_security_groups({
|
64
|
+
filters: [{ name: 'group-name', values: [sg_id] }]
|
65
|
+
})
|
64
66
|
return false unless res[:security_groups].count == 1
|
65
67
|
sgs.find do |sg|
|
66
68
|
sg[:vpc_security_group_id] == res[:security_groups][0][:group_id]
|
@@ -69,9 +71,9 @@ module Awspec::Type
|
|
69
71
|
|
70
72
|
def has_vpc_security_group_tag_name?(sg_id)
|
71
73
|
sgs = @resource_via_client[:vpc_security_groups]
|
72
|
-
res =
|
73
|
-
|
74
|
-
|
74
|
+
res = ec2_client.describe_security_groups({
|
75
|
+
filters: [{ name: 'tag:Name', values: [sg_id] }]
|
76
|
+
})
|
75
77
|
return false unless res[:security_groups].count == 1
|
76
78
|
sgs.find do |sg|
|
77
79
|
sg[:vpc_security_group_id] == res[:security_groups][0][:group_id]
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class RdsDbParameterGroup < Base
|
3
|
-
attr_reader :parameters
|
4
|
-
|
5
3
|
def initialize(name)
|
6
4
|
super
|
7
5
|
@parameters = {}
|
8
|
-
res =
|
9
|
-
|
10
|
-
|
6
|
+
res = rds_client.describe_db_parameters({
|
7
|
+
db_parameter_group_name: name
|
8
|
+
})
|
11
9
|
|
12
10
|
loop do
|
13
11
|
res.parameters.each do |param|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class S3Bucket < Base
|
3
|
+
aws_resource Aws::S3::Bucket
|
4
|
+
|
3
5
|
def initialize(id)
|
4
6
|
super
|
5
7
|
@resource_via_client = find_bucket(id)
|
@@ -7,10 +9,10 @@ module Awspec::Type
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def has_object?(key)
|
10
|
-
res =
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
res = s3_client.head_object({
|
13
|
+
bucket: @id,
|
14
|
+
key: key.sub(%r(\A/), '')
|
15
|
+
})
|
14
16
|
res
|
15
17
|
rescue
|
16
18
|
false
|
@@ -58,10 +60,6 @@ module Awspec::Type
|
|
58
60
|
bp ? (bp.policy.read == policy.gsub(/(\n|\r|\r\n|\s|\t)/, '')) : false
|
59
61
|
end
|
60
62
|
|
61
|
-
def resource
|
62
|
-
@resource ||= Awspec::ResourceReader.new(Aws::S3::Bucket.new(@id))
|
63
|
-
end
|
64
|
-
|
65
63
|
private
|
66
64
|
|
67
65
|
def cors_rules
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class SecurityGroup < Base
|
3
|
-
|
3
|
+
aws_resource Aws::EC2::SecurityGroup
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
super
|
7
|
-
@client = @ec2_client
|
8
7
|
@inbound = true
|
9
8
|
@resource_via_client = find_security_group(id)
|
10
9
|
@id = @resource_via_client[:group_id] if @resource_via_client
|
@@ -7,9 +7,9 @@ module Awspec::Type
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_identity_policy?(name)
|
10
|
-
res =
|
11
|
-
|
12
|
-
|
10
|
+
res = ses_client.list_identity_policies({
|
11
|
+
identity: @id
|
12
|
+
})
|
13
13
|
res[:policy_names].find do |policy_name|
|
14
14
|
policy_name == name
|
15
15
|
end
|
@@ -22,17 +22,17 @@ module Awspec::Type
|
|
22
22
|
|
23
23
|
dkim_attributes.each do |attribute|
|
24
24
|
define_method attribute do
|
25
|
-
res =
|
26
|
-
|
27
|
-
|
25
|
+
res = ses_client.get_identity_dkim_attributes({
|
26
|
+
identities: [@id]
|
27
|
+
})
|
28
28
|
res[:dkim_attributes][@id][attribute.to_sym]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def has_dkim_tokens?(token)
|
33
|
-
res =
|
34
|
-
|
35
|
-
|
33
|
+
res = ses_client.get_identity_dkim_attributes({
|
34
|
+
identities: [@id]
|
35
|
+
})
|
36
36
|
res[:dkim_attributes][@id][:tokens].include?(token)
|
37
37
|
end
|
38
38
|
|
@@ -44,9 +44,9 @@ module Awspec::Type
|
|
44
44
|
|
45
45
|
notification_attributes.each do |attribute|
|
46
46
|
define_method attribute do
|
47
|
-
res =
|
48
|
-
|
49
|
-
|
47
|
+
res = ses_client.get_identity_notification_attributes({
|
48
|
+
identities: [@id]
|
49
|
+
})
|
50
50
|
res[:notification_attributes][@id][attribute.to_sym]
|
51
51
|
end
|
52
52
|
end
|
@@ -58,9 +58,9 @@ module Awspec::Type
|
|
58
58
|
|
59
59
|
verification_attributes.each do |attribute|
|
60
60
|
define_method attribute do
|
61
|
-
res =
|
62
|
-
|
63
|
-
|
61
|
+
res = ses_client.get_identity_verification_attributes({
|
62
|
+
identities: [@id]
|
63
|
+
})
|
64
64
|
res[:verification_attributes][@id][attribute.to_sym]
|
65
65
|
end
|
66
66
|
end
|