awspec 0.55.0 → 0.56.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/lib/awspec.rb +1 -0
- data/lib/awspec/generator/template.rb +6 -3
- data/lib/awspec/shared_context.rb +11 -0
- data/lib/awspec/type/ami.rb +7 -5
- data/lib/awspec/type/autoscaling_group.rb +8 -6
- data/lib/awspec/type/base.rb +15 -7
- data/lib/awspec/type/cloudfront_distribution.rb +8 -6
- data/lib/awspec/type/cloudtrail.rb +10 -8
- data/lib/awspec/type/cloudwatch_alarm.rb +9 -7
- data/lib/awspec/type/cloudwatch_event.rb +8 -6
- data/lib/awspec/type/directconnect_virtual_interface.rb +11 -4
- data/lib/awspec/type/ebs.rb +14 -7
- data/lib/awspec/type/ec2.rb +20 -13
- data/lib/awspec/type/elasticache.rb +13 -6
- data/lib/awspec/type/elasticache_cache_parameter_group.rb +15 -8
- data/lib/awspec/type/elasticsearch.rb +9 -7
- data/lib/awspec/type/elastictranscoder_pipeline.rb +7 -5
- data/lib/awspec/type/elb.rb +11 -9
- data/lib/awspec/type/iam_group.rb +8 -6
- data/lib/awspec/type/iam_policy.rb +8 -6
- data/lib/awspec/type/iam_role.rb +8 -6
- data/lib/awspec/type/iam_user.rb +8 -6
- data/lib/awspec/type/kms.rb +8 -6
- data/lib/awspec/type/lambda.rb +8 -6
- data/lib/awspec/type/launch_configuration.rb +7 -5
- data/lib/awspec/type/nat_gateway.rb +8 -6
- data/lib/awspec/type/network_acl.rb +10 -8
- data/lib/awspec/type/network_interface.rb +14 -12
- data/lib/awspec/type/rds.rb +14 -12
- data/lib/awspec/type/rds_db_cluster_parameter_group.rb +13 -9
- data/lib/awspec/type/rds_db_parameter_group.rb +13 -9
- data/lib/awspec/type/route53_hosted_zone.rb +11 -7
- data/lib/awspec/type/route_table.rb +8 -6
- data/lib/awspec/type/s3_bucket.rb +15 -13
- data/lib/awspec/type/security_group.rb +14 -13
- data/lib/awspec/type/ses_identity.rb +15 -13
- data/lib/awspec/type/subnet.rb +7 -5
- data/lib/awspec/type/vpc.rb +13 -11
- data/lib/awspec/type/waf_web_acl.rb +8 -6
- data/lib/awspec/version.rb +1 -1
- metadata +3 -2
@@ -1,9 +1,16 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Elasticache < Base
|
3
|
-
def initialize(
|
3
|
+
def initialize(name)
|
4
4
|
super
|
5
|
-
@
|
6
|
-
|
5
|
+
@display_name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
def resource_via_client
|
9
|
+
@resource_via_client ||= find_cache_cluster(@display_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
@id ||= resource_via_client.cache_cluster_id if resource_via_client
|
7
14
|
end
|
8
15
|
|
9
16
|
STATES = %w(
|
@@ -15,16 +22,16 @@ module Awspec::Type
|
|
15
22
|
|
16
23
|
STATES.each do |state|
|
17
24
|
define_method state.tr('-', '_') + '?' do
|
18
|
-
|
25
|
+
resource_via_client.cache_cluster_status == state
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
29
|
def has_cache_parameter_group?(group_name)
|
23
|
-
|
30
|
+
resource_via_client.cache_parameter_group.cache_parameter_group_name == group_name
|
24
31
|
end
|
25
32
|
|
26
33
|
def vpc_id
|
27
|
-
cache_subnet_group = find_cache_subnet_group(
|
34
|
+
cache_subnet_group = find_cache_subnet_group(resource_via_client.cache_subnet_group_name)
|
28
35
|
cache_subnet_group.vpc_id if cache_subnet_group
|
29
36
|
end
|
30
37
|
end
|
@@ -2,27 +2,34 @@ module Awspec::Type
|
|
2
2
|
class ElasticacheCacheParameterGroup < Base
|
3
3
|
def initialize(name)
|
4
4
|
super
|
5
|
-
@
|
5
|
+
@display_name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
def resource_via_client
|
9
|
+
return @resource_via_client if @resource_via_client
|
10
|
+
|
11
|
+
parameters = {}
|
6
12
|
res = elasticache_client.describe_cache_parameters({
|
7
|
-
cache_parameter_group_name:
|
13
|
+
cache_parameter_group_name: @display_name
|
8
14
|
})
|
9
15
|
|
10
16
|
loop do
|
11
17
|
res.parameters.each do |param|
|
12
|
-
|
18
|
+
parameters[param.parameter_name] = param.parameter_value
|
13
19
|
end
|
14
20
|
(res.next_page? && res = res.next_page) || break
|
15
21
|
end
|
22
|
+
@resource_via_client ||= parameters
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
@
|
19
|
-
@id
|
25
|
+
def id
|
26
|
+
@id ||= @display_name unless resource_via_client.empty?
|
20
27
|
end
|
21
28
|
|
22
29
|
def method_missing(name)
|
23
30
|
param_name = name.to_s.tr('_', '-')
|
24
|
-
if
|
25
|
-
|
31
|
+
if resource_via_client.include?(param_name)
|
32
|
+
resource_via_client[param_name].to_s
|
26
33
|
else
|
27
34
|
super
|
28
35
|
end
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Elasticsearch < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_elasticsearch_domain(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.arn if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
def has_access_policies?(policy)
|
10
|
-
|
12
|
+
resource_via_client.access_policies == policy.gsub(/\n/, '').gsub(/ /, '')
|
11
13
|
end
|
12
14
|
|
13
15
|
def created?
|
14
|
-
|
16
|
+
resource_via_client.created
|
15
17
|
end
|
16
18
|
|
17
19
|
def deleted?
|
18
|
-
|
20
|
+
resource_via_client.deleted
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class ElastictranscoderPipeline < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_pipeline(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.id if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
STATUSES = %w(
|
@@ -12,7 +14,7 @@ module Awspec::Type
|
|
12
14
|
|
13
15
|
STATUSES.each do |status|
|
14
16
|
define_method status.underscore + '?' do
|
15
|
-
|
17
|
+
resource_via_client.status == status
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/awspec/type/elb.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Elb < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_elb(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id = resource_via_client.load_balancer_name if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
health_check_options = %w(
|
@@ -13,19 +15,19 @@ module Awspec::Type
|
|
13
15
|
|
14
16
|
health_check_options.each do |option|
|
15
17
|
define_method 'health_check_' + option do
|
16
|
-
|
18
|
+
resource_via_client.health_check[option]
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def has_ec2?(id)
|
21
23
|
ec2 = find_ec2(id)
|
22
|
-
|
24
|
+
resource_via_client.instances.find do |instance|
|
23
25
|
instance.instance_id = ec2.instance_id
|
24
26
|
end if ec2
|
25
27
|
end
|
26
28
|
|
27
29
|
def has_security_group?(sg_id)
|
28
|
-
sgs =
|
30
|
+
sgs = resource_via_client.security_groups
|
29
31
|
ret = sgs.find do |sg|
|
30
32
|
sg == sg_id
|
31
33
|
end
|
@@ -38,7 +40,7 @@ module Awspec::Type
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def has_subnet?(subnet_id)
|
41
|
-
subnets =
|
43
|
+
subnets = resource_via_client.subnets
|
42
44
|
ret = subnets.find do |s|
|
43
45
|
s == subnet_id
|
44
46
|
end
|
@@ -50,7 +52,7 @@ module Awspec::Type
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def has_listener?(protocol:, port:, instance_protocol:, instance_port:)
|
53
|
-
|
55
|
+
resource_via_client.listener_descriptions.find do |desc|
|
54
56
|
listener = desc.listener
|
55
57
|
listener.protocol == protocol && listener.load_balancer_port == port && \
|
56
58
|
listener.instance_protocol == instance_protocol && listener.instance_port == instance_port
|
@@ -2,10 +2,12 @@ module Awspec::Type
|
|
2
2
|
class IamGroup < Base
|
3
3
|
aws_resource Aws::IAM::Group
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def resource_via_client
|
6
|
+
@resource_via_client ||= find_iam_group(@display_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
@id ||= resource_via_client.group_id if resource_via_client
|
9
11
|
end
|
10
12
|
|
11
13
|
def has_iam_user?(user_id)
|
@@ -19,7 +21,7 @@ module Awspec::Type
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def has_iam_policy?(policy_id)
|
22
|
-
policies = select_iam_policy_by_group_name(
|
24
|
+
policies = select_iam_policy_by_group_name(resource_via_client.group_name)
|
23
25
|
policies.find do |policy|
|
24
26
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
25
27
|
end
|
@@ -27,7 +29,7 @@ module Awspec::Type
|
|
27
29
|
|
28
30
|
def has_inline_policy?(policy_name, document = nil)
|
29
31
|
res = iam_client.get_group_policy({
|
30
|
-
group_name:
|
32
|
+
group_name: resource_via_client.group_name,
|
31
33
|
policy_name: policy_name
|
32
34
|
})
|
33
35
|
return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class IamPolicy < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_iam_policy(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.policy_id if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
def attachable?
|
10
|
-
|
12
|
+
resource_via_client.is_attachable
|
11
13
|
end
|
12
14
|
|
13
15
|
def attached_to_user?(user_id = nil)
|
14
|
-
users = select_attached_users(
|
16
|
+
users = select_attached_users(id)
|
15
17
|
if user_id
|
16
18
|
user = find_iam_user(user_id)
|
17
19
|
return false unless user
|
data/lib/awspec/type/iam_role.rb
CHANGED
@@ -2,14 +2,16 @@ module Awspec::Type
|
|
2
2
|
class IamRole < Base
|
3
3
|
aws_resource Aws::IAM::Role
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def resource_via_client
|
6
|
+
@resource_via_client ||= find_iam_role(@display_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
@id ||= resource_via_client.role_id if resource_via_client
|
9
11
|
end
|
10
12
|
|
11
13
|
def has_iam_policy?(policy_id)
|
12
|
-
policies = select_iam_policy_by_role_name(
|
14
|
+
policies = select_iam_policy_by_role_name(resource_via_client.role_name)
|
13
15
|
policies.find do |policy|
|
14
16
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
15
17
|
end
|
@@ -17,7 +19,7 @@ module Awspec::Type
|
|
17
19
|
|
18
20
|
def has_inline_policy?(policy_name, document = nil)
|
19
21
|
res = iam_client.get_role_policy({
|
20
|
-
role_name:
|
22
|
+
role_name: resource_via_client.role_name,
|
21
23
|
policy_name: policy_name
|
22
24
|
})
|
23
25
|
return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
|
data/lib/awspec/type/iam_user.rb
CHANGED
@@ -2,14 +2,16 @@ module Awspec::Type
|
|
2
2
|
class IamUser < Base
|
3
3
|
aws_resource Aws::IAM::User
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def resource_via_client
|
6
|
+
@resource_via_client ||= find_iam_user(@display_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
@id ||= resource_via_client.user_name if resource_via_client
|
9
11
|
end
|
10
12
|
|
11
13
|
def has_iam_policy?(policy_id)
|
12
|
-
policies = select_iam_policy_by_user_name(
|
14
|
+
policies = select_iam_policy_by_user_name(resource_via_client.user_name)
|
13
15
|
policies.find do |policy|
|
14
16
|
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
15
17
|
end
|
@@ -17,7 +19,7 @@ module Awspec::Type
|
|
17
19
|
|
18
20
|
def has_inline_policy?(policy_name, document = nil)
|
19
21
|
res = iam_client.get_user_policy({
|
20
|
-
user_name:
|
22
|
+
user_name: resource_via_client.user_name,
|
21
23
|
policy_name: policy_name
|
22
24
|
})
|
23
25
|
return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
|
data/lib/awspec/type/kms.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Kms < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_kms_key_by_alias(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.arn if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
def enabled?
|
10
|
-
|
12
|
+
resource_via_client.enabled
|
11
13
|
end
|
12
14
|
|
13
15
|
def has_key_policy?(policy_name, document = nil)
|
14
|
-
res = kms_client.get_key_policy(key_id:
|
16
|
+
res = kms_client.get_key_policy(key_id: id, policy_name: policy_name)
|
15
17
|
return JSON.parse(URI.decode(res.policy)) == JSON.parse(document) if document
|
16
18
|
res
|
17
19
|
end
|
data/lib/awspec/type/lambda.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class Lambda < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_lambda(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.function_arn if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
def timeout
|
10
|
-
|
12
|
+
resource_via_client.timeout
|
11
13
|
end
|
12
14
|
|
13
15
|
def has_event_source?(event_source_arn)
|
14
|
-
sources = select_event_source_by_function_arn(
|
16
|
+
sources = select_event_source_by_function_arn(id)
|
15
17
|
sources.find do |source|
|
16
18
|
source.event_source_arn == event_source_arn
|
17
19
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class LaunchConfiguration < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_launch_configuration(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.launch_configuration_arn if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
def has_security_group?(sg_id)
|
10
|
-
sgs =
|
12
|
+
sgs = resource_via_client.security_groups
|
11
13
|
ret = sgs.find do |sg|
|
12
14
|
sg == sg_id
|
13
15
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Awspec::Type
|
2
2
|
class NatGateway < Base
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_nat_gateway(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.nat_gateway_id if resource_via_client
|
7
9
|
end
|
8
10
|
|
9
11
|
STATES = %w(
|
@@ -12,12 +14,12 @@ module Awspec::Type
|
|
12
14
|
|
13
15
|
STATES.each do |state|
|
14
16
|
define_method state.tr('-', '_') + '?' do
|
15
|
-
|
17
|
+
resource_via_client.state == state
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
def has_eip?(ip_address = nil)
|
20
|
-
|
22
|
+
resource_via_client.nat_gateway_addresses.find do |address|
|
21
23
|
return address.public_ip == ip_address
|
22
24
|
end
|
23
25
|
end
|
@@ -3,14 +3,16 @@ module Awspec::Type
|
|
3
3
|
aws_resource Aws::EC2::NetworkAcl
|
4
4
|
tags_allowed
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def resource_via_client
|
7
|
+
@resource_via_client ||= find_network_acl(@display_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def id
|
11
|
+
@id ||= resource_via_client.network_acl_id if resource_via_client
|
10
12
|
end
|
11
13
|
|
12
14
|
def has_subnet?(subnet_id)
|
13
|
-
|
15
|
+
resource_via_client.associations.find do |a|
|
14
16
|
next true if a.subnet_id == subnet_id
|
15
17
|
subnet = find_subnet(subnet_id)
|
16
18
|
next false unless subnet
|
@@ -39,13 +41,13 @@ module Awspec::Type
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def inbound_entries_count
|
42
|
-
|
44
|
+
resource_via_client.entries.count do |entry|
|
43
45
|
entry.egress == false
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
def outbound_entries_count
|
48
|
-
|
50
|
+
resource_via_client.entries.count do |entry|
|
49
51
|
entry.egress == true
|
50
52
|
end
|
51
53
|
end
|
@@ -71,7 +73,7 @@ module Awspec::Type
|
|
71
73
|
private
|
72
74
|
|
73
75
|
def entry?(rule_action, port = nil, protocol = nil, cidr = nil, rule_number = nil)
|
74
|
-
|
76
|
+
resource_via_client.entries.find do |entry|
|
75
77
|
# egress rule_action
|
76
78
|
next false if entry.egress != @egress
|
77
79
|
next false if entry.rule_action != rule_action
|