awspec 0.69.1 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -1
- data/.travis.yml +1 -0
- data/Rakefile +10 -1
- data/awspec.gemspec +3 -3
- data/doc/_resource_types/cloudwatch_logs.md +40 -0
- data/doc/_resource_types/ec2_account_attributes.md +8 -0
- data/doc/_resource_types/lambda_account_settings.md +10 -0
- data/doc/_resource_types/rds_account_attributes.md +8 -0
- data/doc/_resource_types/ses_send_quota.md +9 -0
- data/doc/contributing.md +10 -0
- data/doc/resource_types.md +262 -27
- data/lib/awspec/error.rb +2 -0
- data/lib/awspec/ext.rb +1 -0
- data/lib/awspec/ext/hash.rb +10 -0
- data/lib/awspec/generator.rb +6 -0
- data/lib/awspec/generator/doc/type.rb +35 -1
- data/lib/awspec/generator/doc/type/account.rb +71 -0
- data/lib/awspec/generator/doc/type/account_attribute.rb +69 -0
- data/lib/awspec/generator/doc/type/account_attribute_base.rb +32 -0
- data/lib/awspec/generator/doc/type/base.rb +10 -3
- data/lib/awspec/generator/doc/type/cloudwatch_logs.rb +17 -0
- data/lib/awspec/generator/doc/type/ec2_account_attributes.rb +17 -0
- data/lib/awspec/generator/doc/type/lambda_account_settings.rb +17 -0
- data/lib/awspec/generator/doc/type/rds_account_attributes.rb +17 -0
- data/lib/awspec/generator/doc/type/ses_send_quota.rb +17 -0
- data/lib/awspec/generator/template.rb +38 -1
- data/lib/awspec/helper/finder.rb +8 -1
- data/lib/awspec/helper/finder/account_attributes.rb +61 -0
- data/lib/awspec/helper/finder/cloudwatch_logs.rb +35 -0
- data/lib/awspec/helper/type.rb +31 -0
- data/lib/awspec/matcher.rb +3 -0
- data/lib/awspec/matcher/have_subscription_filter.rb +9 -0
- data/lib/awspec/shared_context.rb +8 -0
- data/lib/awspec/stub/account.rb +146 -0
- data/lib/awspec/stub/cloudwatch_logs.rb +34 -0
- data/lib/awspec/stub/ecs.rb +9 -9
- data/lib/awspec/stub/ecs_cluster.rb +9 -9
- data/lib/awspec/stub/ecs_container_instance.rb +9 -9
- data/lib/awspec/toolbox.rb +6 -1
- data/lib/awspec/type/account.rb +35 -0
- data/lib/awspec/type/account_attribute.rb +28 -0
- data/lib/awspec/type/account_attribute_base.rb +4 -0
- data/lib/awspec/type/acm.rb +1 -1
- data/lib/awspec/type/alb.rb +1 -1
- data/lib/awspec/type/ami.rb +1 -1
- data/lib/awspec/type/autoscaling_group.rb +3 -2
- data/lib/awspec/type/base.rb +6 -25
- data/lib/awspec/type/cloudfront_distribution.rb +1 -1
- data/lib/awspec/type/cloudtrail.rb +1 -1
- data/lib/awspec/type/cloudwatch_alarm.rb +1 -1
- data/lib/awspec/type/cloudwatch_event.rb +1 -1
- data/lib/awspec/type/cloudwatch_logs.rb +27 -0
- data/lib/awspec/type/customer_gateway.rb +1 -1
- data/lib/awspec/type/directconnect_virtual_interface.rb +1 -1
- data/lib/awspec/type/ebs.rb +1 -1
- data/lib/awspec/type/ec2.rb +1 -1
- data/lib/awspec/type/ec2_account_attributes.rb +7 -0
- data/lib/awspec/type/ecr_repository.rb +1 -1
- data/lib/awspec/type/ecs_cluster.rb +1 -1
- data/lib/awspec/type/ecs_container_instance.rb +1 -1
- data/lib/awspec/type/ecs_service.rb +1 -1
- data/lib/awspec/type/ecs_task_definition.rb +1 -1
- data/lib/awspec/type/efs.rb +1 -1
- data/lib/awspec/type/elasticache.rb +1 -1
- data/lib/awspec/type/elasticache_cache_parameter_group.rb +1 -1
- data/lib/awspec/type/elasticsearch.rb +1 -1
- data/lib/awspec/type/elastictranscoder_pipeline.rb +1 -1
- data/lib/awspec/type/elb.rb +3 -2
- data/lib/awspec/type/iam_group.rb +1 -1
- data/lib/awspec/type/iam_policy.rb +1 -1
- data/lib/awspec/type/iam_role.rb +1 -1
- data/lib/awspec/type/iam_user.rb +1 -1
- data/lib/awspec/type/internet_gateway.rb +1 -1
- data/lib/awspec/type/kms.rb +1 -1
- data/lib/awspec/type/lambda.rb +1 -1
- data/lib/awspec/type/lambda_account_settings.rb +7 -0
- data/lib/awspec/type/launch_configuration.rb +1 -1
- data/lib/awspec/type/nat_gateway.rb +1 -1
- data/lib/awspec/type/network_acl.rb +1 -1
- data/lib/awspec/type/network_interface.rb +1 -1
- data/lib/awspec/type/rds.rb +1 -1
- data/lib/awspec/type/rds_account_attributes.rb +7 -0
- data/lib/awspec/type/rds_db_cluster_parameter_group.rb +1 -1
- data/lib/awspec/type/rds_db_parameter_group.rb +1 -1
- data/lib/awspec/type/resource_base.rb +24 -0
- data/lib/awspec/type/route53_hosted_zone.rb +1 -1
- data/lib/awspec/type/route_table.rb +1 -1
- data/lib/awspec/type/s3_bucket.rb +1 -1
- data/lib/awspec/type/security_group.rb +1 -1
- data/lib/awspec/type/ses_identity.rb +1 -1
- data/lib/awspec/type/ses_send_quota.rb +7 -0
- data/lib/awspec/type/subnet.rb +1 -1
- data/lib/awspec/type/vpc.rb +1 -1
- data/lib/awspec/type/vpn_connection.rb +1 -1
- data/lib/awspec/type/vpn_gateway.rb +1 -1
- data/lib/awspec/type/waf_web_acl.rb +1 -1
- data/lib/awspec/version.rb +1 -1
- metadata +36 -8
@@ -30,10 +30,10 @@ Aws.config[:ecs] = {
|
|
30
30
|
integer_value: 0,
|
31
31
|
long_value: 0,
|
32
32
|
string_set_value: %w[
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
2376
|
34
|
+
22
|
35
|
+
51678
|
36
|
+
2375
|
37
37
|
]
|
38
38
|
}
|
39
39
|
],
|
@@ -59,11 +59,11 @@ Aws.config[:ecs] = {
|
|
59
59
|
integer_value: 0,
|
60
60
|
long_value: 0,
|
61
61
|
string_set_value: %w[
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
2376
|
63
|
+
22
|
64
|
+
80
|
65
|
+
51678
|
66
|
+
2375
|
67
67
|
]
|
68
68
|
}
|
69
69
|
],
|
data/lib/awspec/toolbox.rb
CHANGED
@@ -6,8 +6,13 @@ module Awspec
|
|
6
6
|
end
|
7
7
|
|
8
8
|
desc 'template [resource_type_name]', 'Generate template files'
|
9
|
+
option :account_attribute, type: :boolean, default: false, aliases: :a
|
9
10
|
def template(type)
|
10
|
-
|
11
|
+
if options[:account_attribute]
|
12
|
+
puts Awspec::Generator::Template.generate_account_attribute(type)
|
13
|
+
else
|
14
|
+
puts Awspec::Generator::Template.generate(type)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class Account < Base
|
3
|
+
REMOVE_SUFFIX_RE = /
|
4
|
+
_account_attributes|_account_settings|_send_quota
|
5
|
+
/ix
|
6
|
+
|
7
|
+
def resource_via_client
|
8
|
+
attributes = sts_client.get_caller_identity.to_h
|
9
|
+
Awspec::Helper::Type::ACCOUNT_ATTRIBUTES.each do |type|
|
10
|
+
key = type.gsub(REMOVE_SUFFIX_RE, '').to_sym
|
11
|
+
if key == 'ses'
|
12
|
+
# https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html
|
13
|
+
next unless ['us-east-1', 'us-west-2', 'eu-west-1'].include?(Aws.config[:region])
|
14
|
+
end
|
15
|
+
eval "attributes[key] = Awspec::Type::#{type.camelize}.new.resource_via_client"
|
16
|
+
end
|
17
|
+
@resource_via_client ||= attributes.to_struct
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
@id ||= sts_client.get_caller_identity.account
|
22
|
+
end
|
23
|
+
|
24
|
+
def lambda
|
25
|
+
resource_via_client[:lambda]
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_missing(name)
|
29
|
+
name = name.to_s if name.class == Symbol
|
30
|
+
describe = name.tr('-', '_').to_sym
|
31
|
+
super unless resource_via_client.members.include?(describe)
|
32
|
+
resource_via_client[describe]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class AccountAttribute < Base
|
3
|
+
def initialize(key = nil)
|
4
|
+
@key = key.to_sym
|
5
|
+
end
|
6
|
+
|
7
|
+
def resource_via_client
|
8
|
+
attributes = nil
|
9
|
+
Awspec::Helper::Type::ACCOUNT_ATTRIBUTES.each do |type|
|
10
|
+
key = type.gsub(Awspec::Type::Account::REMOVE_SUFFIX_RE, '').to_sym
|
11
|
+
next unless key == @key
|
12
|
+
if key == 'ses'
|
13
|
+
# https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html
|
14
|
+
next unless ['us-east-1', 'us-west-2', 'eu-west-1'].include?(Aws.config[:region])
|
15
|
+
end
|
16
|
+
eval "attributes = Awspec::Type::#{type.camelize}.new.resource_via_client"
|
17
|
+
end
|
18
|
+
@resource_via_client ||= attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(name)
|
22
|
+
name = name.to_s if name.class == Symbol
|
23
|
+
describe = name.tr('-', '_').to_sym
|
24
|
+
super unless resource_via_client.members.include?(describe)
|
25
|
+
resource_via_client[describe]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/awspec/type/acm.rb
CHANGED
data/lib/awspec/type/alb.rb
CHANGED
data/lib/awspec/type/ami.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Awspec::Type
|
2
|
-
class AutoscalingGroup <
|
2
|
+
class AutoscalingGroup < ResourceBase
|
3
3
|
aws_resource Aws::AutoScaling::AutoScalingGroup
|
4
4
|
tags_allowed
|
5
5
|
|
@@ -19,9 +19,10 @@ module Awspec::Type
|
|
19
19
|
|
20
20
|
def has_ec2?(id)
|
21
21
|
ec2 = find_ec2(id)
|
22
|
+
return nil unless ec2
|
22
23
|
resource_via_client.instances.find do |instance|
|
23
24
|
instance.instance_id = ec2.instance_id
|
24
|
-
end
|
25
|
+
end
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/lib/awspec/type/base.rb
CHANGED
@@ -6,12 +6,10 @@ module Awspec::Type
|
|
6
6
|
class Base
|
7
7
|
include Awspec::Helper::Finder
|
8
8
|
include Awspec::BlackListForwardable
|
9
|
+
attr_accessor :account
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(display_name = nil)
|
13
|
-
@display_name = display_name
|
14
|
-
@id = nil
|
11
|
+
def resource_via_client
|
12
|
+
raise 'this method must be override!'
|
15
13
|
end
|
16
14
|
|
17
15
|
def to_s
|
@@ -23,24 +21,6 @@ module Awspec::Type
|
|
23
21
|
to_s
|
24
22
|
end
|
25
23
|
|
26
|
-
def exists?
|
27
|
-
id
|
28
|
-
end
|
29
|
-
|
30
|
-
def id
|
31
|
-
raise 'this method must be override!'
|
32
|
-
end
|
33
|
-
|
34
|
-
def resource_via_client
|
35
|
-
raise 'this method must be override!'
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.aws_resource(resource)
|
39
|
-
define_method :resource do
|
40
|
-
@resource ||= Awspec::ResourceReader.new(resource.new(id))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
24
|
def self.tags_allowed
|
45
25
|
define_method :has_tag? do |key, value|
|
46
26
|
begin
|
@@ -54,8 +34,9 @@ module Awspec::Type
|
|
54
34
|
end
|
55
35
|
|
56
36
|
def method_missing(name)
|
57
|
-
|
58
|
-
|
37
|
+
name_str = name.to_s if name.class == Symbol
|
38
|
+
describe = name_str.tr('-', '_').to_sym
|
39
|
+
if !resource_via_client.nil? && resource_via_client.members.include?(describe)
|
59
40
|
resource_via_client[describe]
|
60
41
|
else
|
61
42
|
super unless self.respond_to?(:resource)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class CloudwatchLogs < ResourceBase
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_cloudwatch_logs_group(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.log_group_name if resource_via_client
|
9
|
+
end
|
10
|
+
|
11
|
+
def has_log_stream?(stream_name)
|
12
|
+
ret = find_cloudwatch_logs_stream_by_log_group_name(@id).log_stream_name
|
13
|
+
return true if ret == stream_name
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_metric_filter?(filter_name)
|
17
|
+
ret = find_cloudwatch_logs_metric_fileter_by_log_group_name(@id, filter_name).filter_name
|
18
|
+
return true if ret == filter_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_subscription_filter?(filter_name, pattern = nil)
|
22
|
+
ret = find_cloudwatch_logs_subscription_fileter_by_log_group_name(@id, filter_name)
|
23
|
+
return false unless ret.filter_pattern == pattern
|
24
|
+
return true if ret.filter_name == filter_name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/awspec/type/ebs.rb
CHANGED
data/lib/awspec/type/ec2.rb
CHANGED
data/lib/awspec/type/efs.rb
CHANGED
data/lib/awspec/type/elb.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Awspec::Type
|
2
|
-
class Elb <
|
2
|
+
class Elb < ResourceBase
|
3
3
|
def resource_via_client
|
4
4
|
@resource_via_client ||= find_elb(@display_name)
|
5
5
|
end
|
@@ -21,9 +21,10 @@ module Awspec::Type
|
|
21
21
|
|
22
22
|
def has_ec2?(id)
|
23
23
|
ec2 = find_ec2(id)
|
24
|
+
return nil unless ec2
|
24
25
|
resource_via_client.instances.find do |instance|
|
25
26
|
instance.instance_id = ec2.instance_id
|
26
|
-
end
|
27
|
+
end
|
27
28
|
end
|
28
29
|
|
29
30
|
def has_security_group?(sg_id)
|
data/lib/awspec/type/iam_role.rb
CHANGED
data/lib/awspec/type/iam_user.rb
CHANGED