awspec 1.33.0 → 1.35.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/.github/release.yml +4 -0
- data/.github/workflows/ci.yml +7 -7
- data/.github/workflows/doc.yml +4 -4
- data/.github/workflows/tagpr.yml +58 -0
- data/.tagpr +37 -0
- data/CHANGELOG.md +104 -0
- data/doc/resource_types.md +12 -10
- data/lib/awspec/generator/doc/type/account.rb +1 -1
- data/lib/awspec/generator/doc/type/account_attribute.rb +2 -1
- data/lib/awspec/generator/doc/type/base.rb +1 -1
- data/lib/awspec/generator/doc/type.rb +1 -1
- data/lib/awspec/generator/spec/acm.rb +1 -1
- data/lib/awspec/generator/spec/alb.rb +1 -1
- data/lib/awspec/generator/spec/alb_listener.rb +1 -1
- data/lib/awspec/generator/spec/autoscaling_group.rb +1 -1
- data/lib/awspec/generator/spec/cloudwatch_alarm.rb +1 -1
- data/lib/awspec/generator/spec/cloudwatch_event.rb +1 -1
- data/lib/awspec/generator/spec/cloudwatch_logs.rb +1 -1
- data/lib/awspec/generator/spec/codebuild.rb +1 -1
- data/lib/awspec/generator/spec/codepipeline.rb +1 -1
- data/lib/awspec/generator/spec/directconnect.rb +1 -1
- data/lib/awspec/generator/spec/ebs.rb +2 -2
- data/lib/awspec/generator/spec/ec2.rb +1 -1
- data/lib/awspec/generator/spec/efs.rb +1 -1
- data/lib/awspec/generator/spec/eip.rb +1 -1
- data/lib/awspec/generator/spec/elasticache.rb +1 -1
- data/lib/awspec/generator/spec/elasticsearch.rb +1 -1
- data/lib/awspec/generator/spec/elb.rb +1 -1
- data/lib/awspec/generator/spec/iam_group.rb +1 -1
- data/lib/awspec/generator/spec/iam_policy.rb +1 -1
- data/lib/awspec/generator/spec/iam_role.rb +1 -1
- data/lib/awspec/generator/spec/iam_user.rb +1 -1
- data/lib/awspec/generator/spec/internet_gateway.rb +1 -1
- data/lib/awspec/generator/spec/kms.rb +1 -1
- data/lib/awspec/generator/spec/lambda.rb +1 -1
- data/lib/awspec/generator/spec/managed_prefix_list.rb +1 -1
- data/lib/awspec/generator/spec/nat_gateway.rb +1 -1
- data/lib/awspec/generator/spec/network_acl.rb +1 -1
- data/lib/awspec/generator/spec/network_interface.rb +1 -1
- data/lib/awspec/generator/spec/nlb.rb +1 -1
- data/lib/awspec/generator/spec/nlb_listener.rb +1 -1
- data/lib/awspec/generator/spec/rds.rb +1 -1
- data/lib/awspec/generator/spec/rds_db_cluster.rb +1 -1
- data/lib/awspec/generator/spec/rds_db_cluster_parameter_group.rb +1 -1
- data/lib/awspec/generator/spec/rds_db_parameter_group.rb +1 -1
- data/lib/awspec/generator/spec/rds_global_cluster.rb +1 -1
- data/lib/awspec/generator/spec/rds_proxy.rb +1 -1
- data/lib/awspec/generator/spec/redshift.rb +1 -1
- data/lib/awspec/generator/spec/redshift_cluster_parameter_group.rb +1 -1
- data/lib/awspec/generator/spec/route53_hosted_zone.rb +2 -2
- data/lib/awspec/generator/spec/route_table.rb +10 -6
- data/lib/awspec/generator/spec/s3_bucket.rb +3 -3
- data/lib/awspec/generator/spec/security_group.rb +3 -3
- data/lib/awspec/generator/spec/subnet.rb +1 -1
- data/lib/awspec/generator/spec/vpc.rb +1 -1
- data/lib/awspec/generator/spec/wafv2_ip_set.rb +1 -1
- data/lib/awspec/generator/spec/wafv2_web_acl.rb +1 -1
- data/lib/awspec/helper/finder/backup.rb +9 -0
- data/lib/awspec/helper/finder/iam.rb +17 -1
- data/lib/awspec/matcher/have_plan_rule.rb +38 -0
- data/lib/awspec/matcher.rb +3 -0
- data/lib/awspec/stub/backup_plan.rb +38 -0
- data/lib/awspec/stub/iam_policy.rb +15 -1
- data/lib/awspec/stub/iam_role.rb +11 -1
- data/lib/awspec/type/backup_plan.rb +40 -0
- data/lib/awspec/version.rb +1 -1
- metadata +8 -3
|
@@ -17,7 +17,7 @@ module Awspec::Generator
|
|
|
17
17
|
document = JSON.generate(JSON.parse(URI.decode_www_form_component(res.policy_document)))
|
|
18
18
|
"it { should have_inline_policy('#{policy_name}').policy_document('#{document}') }"
|
|
19
19
|
end
|
|
20
|
-
content = ERB.new(iam_group_spec_template,
|
|
20
|
+
content = ERB.new(iam_group_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
21
21
|
end
|
|
22
22
|
specs.join("\n")
|
|
23
23
|
end
|
|
@@ -8,7 +8,7 @@ module Awspec::Generator
|
|
|
8
8
|
policies = select_all_attached_policies
|
|
9
9
|
raise 'Not Found policy' if policies.empty?
|
|
10
10
|
|
|
11
|
-
ERB.new(policy_spec_template,
|
|
11
|
+
ERB.new(policy_spec_template, trim_mode: '-').result(binding).chomp
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# rubocop:disable all
|
|
@@ -17,7 +17,7 @@ module Awspec::Generator
|
|
|
17
17
|
document = JSON.generate(JSON.parse(URI.decode_www_form_component(res.policy_document)))
|
|
18
18
|
"it { should have_inline_policy('#{policy_name}').policy_document('#{document}') }"
|
|
19
19
|
end
|
|
20
|
-
content = ERB.new(iam_role_spec_template,
|
|
20
|
+
content = ERB.new(iam_role_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
21
21
|
end
|
|
22
22
|
specs.join("\n")
|
|
23
23
|
end
|
|
@@ -17,7 +17,7 @@ module Awspec::Generator
|
|
|
17
17
|
document = JSON.generate(JSON.parse(URI.decode_www_form_component(res.policy_document)))
|
|
18
18
|
"it { should have_inline_policy('#{policy_name}').policy_document('#{document}') }"
|
|
19
19
|
end
|
|
20
|
-
content = ERB.new(iam_user_spec_template,
|
|
20
|
+
content = ERB.new(iam_user_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
21
21
|
end
|
|
22
22
|
specs.join("\n")
|
|
23
23
|
end
|
|
@@ -15,7 +15,7 @@ module Awspec::Generator
|
|
|
15
15
|
internet_gateways = select_internet_gateway_by_vpc_id(@vpc_id)
|
|
16
16
|
specs = internet_gateways.map do |internet_gateway|
|
|
17
17
|
internet_gateway_id = internet_gateway[:internet_gateway_id]
|
|
18
|
-
content = ERB.new(internet_gateway_spec_template,
|
|
18
|
+
content = ERB.new(internet_gateway_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
19
19
|
end
|
|
20
20
|
specs.join("\n")
|
|
21
21
|
end
|
|
@@ -8,7 +8,7 @@ module Awspec::Generator
|
|
|
8
8
|
aliases = select_all_kms_aliases.select { |kms_alias| customer_managed_key?(kms_alias) }
|
|
9
9
|
raise 'Not Found alias' if aliases.empty?
|
|
10
10
|
|
|
11
|
-
ERB.new(keys_spec_template,
|
|
11
|
+
ERB.new(keys_spec_template, trim_mode: '-').result(binding).chomp
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def keys_spec_template
|
|
@@ -8,7 +8,7 @@ module Awspec::Generator
|
|
|
8
8
|
lambda_functions = select_all_lambda_functions
|
|
9
9
|
raise 'Not Found lambda' if lambda_functions.empty?
|
|
10
10
|
|
|
11
|
-
ERB.new(lambda_spec_template,
|
|
11
|
+
ERB.new(lambda_spec_template, trim_mode: '-').result(binding).chomp
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def lambda_spec_template
|
|
@@ -15,7 +15,7 @@ module Awspec::Generator
|
|
|
15
15
|
|
|
16
16
|
specs = prefix_lists.map do |prefix_list|
|
|
17
17
|
entries = select_managed_prefix_list_entries(prefix_list.prefix_list_id)
|
|
18
|
-
content = ERB.new(managed_prefix_list_spec_template,
|
|
18
|
+
content = ERB.new(managed_prefix_list_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
19
19
|
end
|
|
20
20
|
specs.join("\n")
|
|
21
21
|
end
|
|
@@ -15,7 +15,7 @@ module Awspec::Generator
|
|
|
15
15
|
nat_gateways = select_nat_gateway_by_vpc_id(@vpc_id)
|
|
16
16
|
specs = nat_gateways.map do |nat_gateway|
|
|
17
17
|
nat_gateway_id = nat_gateway[:nat_gateway_id]
|
|
18
|
-
content = ERB.new(nat_gateway_spec_template,
|
|
18
|
+
content = ERB.new(nat_gateway_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
19
19
|
end
|
|
20
20
|
specs.join("\n")
|
|
21
21
|
end
|
|
@@ -24,7 +24,7 @@ module Awspec::Generator
|
|
|
24
24
|
outbound_entries_count = acl.entries.count do |entry|
|
|
25
25
|
entry.egress == true
|
|
26
26
|
end
|
|
27
|
-
content = ERB.new(network_acl_spec_template,
|
|
27
|
+
content = ERB.new(network_acl_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
28
28
|
end
|
|
29
29
|
specs.join("\n")
|
|
30
30
|
end
|
|
@@ -19,7 +19,7 @@ module Awspec::Generator
|
|
|
19
19
|
network_interface_id = interface[:network_interface_id]
|
|
20
20
|
linespecs = generate_linespecs(interface)
|
|
21
21
|
private_ip_addresses_count = interface.private_ip_addresses.count
|
|
22
|
-
content = ERB.new(network_interface_spec_template,
|
|
22
|
+
content = ERB.new(network_interface_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
23
23
|
end
|
|
24
24
|
specs.join("\n")
|
|
25
25
|
end
|
|
@@ -16,7 +16,7 @@ module Awspec::Generator
|
|
|
16
16
|
nlbs = select_nlb_by_vpc_id(@vpc_id)
|
|
17
17
|
|
|
18
18
|
specs = nlbs.map do |nlb|
|
|
19
|
-
content = ERB.new(nlb_spec_template,
|
|
19
|
+
content = ERB.new(nlb_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
20
20
|
end
|
|
21
21
|
specs.join("\n")
|
|
22
22
|
end
|
|
@@ -20,7 +20,7 @@ module Awspec::Generator
|
|
|
20
20
|
nlb_listeners.map do |listener|
|
|
21
21
|
rules = select_rule_by_nlb_listener_id(listener.listener_arn).map(&:to_h)
|
|
22
22
|
rules.map do |rule|
|
|
23
|
-
content = ERB.new(nlb_listener_spec_template,
|
|
23
|
+
content = ERB.new(nlb_listener_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -21,7 +21,7 @@ module Awspec::Generator
|
|
|
21
21
|
ret = find_security_group(sg_id)
|
|
22
22
|
ret[:group_name]
|
|
23
23
|
end
|
|
24
|
-
content = ERB.new(rds_spec_template,
|
|
24
|
+
content = ERB.new(rds_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
25
25
|
end
|
|
26
26
|
specs.join("\n")
|
|
27
27
|
end
|
|
@@ -7,7 +7,7 @@ module Awspec::Generator
|
|
|
7
7
|
def generate_by_parameter_group(parameter_group)
|
|
8
8
|
@parameter_group = parameter_group
|
|
9
9
|
res = select_all_rds_db_cluster_parameters(@parameter_group)
|
|
10
|
-
ERB.new(db_cluster_parameter_group_template,
|
|
10
|
+
ERB.new(db_cluster_parameter_group_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def db_cluster_parameter_group_template
|
|
@@ -7,7 +7,7 @@ module Awspec::Generator
|
|
|
7
7
|
def generate_by_parameter_group(parameter_group)
|
|
8
8
|
@parameter_group = parameter_group
|
|
9
9
|
res = select_all_rds_db_parameters(@parameter_group)
|
|
10
|
-
ERB.new(db_parameter_group_template,
|
|
10
|
+
ERB.new(db_parameter_group_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def db_parameter_group_template
|
|
@@ -11,7 +11,7 @@ module Awspec::Generator
|
|
|
11
11
|
@vpc_id = vpc[:vpc_id]
|
|
12
12
|
db_proxies = select_rds_proxy_by_vpc_id(@vpc_id)
|
|
13
13
|
specs = db_proxies.map do |db_proxy|
|
|
14
|
-
content = ERB.new(rds_proxy_spec_template,
|
|
14
|
+
content = ERB.new(rds_proxy_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
15
15
|
end
|
|
16
16
|
specs.join("\n")
|
|
17
17
|
end
|
|
@@ -24,7 +24,7 @@ module Awspec::Generator
|
|
|
24
24
|
ret = find_security_group(sg_id)
|
|
25
25
|
ret[:group_name]
|
|
26
26
|
end
|
|
27
|
-
content = ERB.new(redshift_spec_template,
|
|
27
|
+
content = ERB.new(redshift_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
28
28
|
end
|
|
29
29
|
specs.join("\n")
|
|
30
30
|
end
|
|
@@ -7,7 +7,7 @@ module Awspec::Generator
|
|
|
7
7
|
def generate_by_parameter_group(parameter_group)
|
|
8
8
|
@parameter_group = parameter_group
|
|
9
9
|
res = select_all_redshift_cluster_parameters(@parameter_group)
|
|
10
|
-
ERB.new(redshift_cluster_parameters_spec_template,
|
|
10
|
+
ERB.new(redshift_cluster_parameters_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def redshift_cluster_parameters_spec_template
|
|
@@ -28,7 +28,7 @@ module Awspec::Generator
|
|
|
28
28
|
generate_linespec(record_set)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
content = ERB.new(route53_hosted_zone_spec_template,
|
|
31
|
+
content = ERB.new(route53_hosted_zone_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def generate_linespec(record_set)
|
|
@@ -55,7 +55,7 @@ it { should have_record_set('<%= name %>').alias('<%= dns_name %>', '<%= hosted_
|
|
|
55
55
|
<% end -%>
|
|
56
56
|
EOF
|
|
57
57
|
end
|
|
58
|
-
ERB.new(template,
|
|
58
|
+
ERB.new(template, trim_mode: '-').result(binding)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def route53_hosted_zone_spec_template
|
|
@@ -18,7 +18,7 @@ module Awspec::Generator
|
|
|
18
18
|
subnet_linespecs = generate_subnet_linespecs(route_table)
|
|
19
19
|
route_table_id = route_table[:route_table_id]
|
|
20
20
|
route_table_tag_name = route_table.tag_name
|
|
21
|
-
content = ERB.new(route_table_spec_template,
|
|
21
|
+
content = ERB.new(route_table_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
22
22
|
end
|
|
23
23
|
specs.join("\n")
|
|
24
24
|
end
|
|
@@ -29,18 +29,22 @@ module Awspec::Generator
|
|
|
29
29
|
if route.gateway_id
|
|
30
30
|
destination = route.destination_cidr_block
|
|
31
31
|
destination ||= route.destination_prefix_list_id
|
|
32
|
-
linespecs.push(ERB.new(route_table_spec_gateway_linetemplate,
|
|
32
|
+
linespecs.push(ERB.new(route_table_spec_gateway_linetemplate, trim_mode: '-').result(binding))
|
|
33
33
|
end
|
|
34
34
|
if route.instance_id
|
|
35
35
|
instance = find_ec2(route.instance_id)
|
|
36
|
-
|
|
36
|
+
if instance
|
|
37
|
+
linespecs.push(ERB.new(route_table_spec_instance_linetemplate, trim_mode: '-').result(binding))
|
|
38
|
+
end
|
|
37
39
|
end
|
|
38
40
|
if route.vpc_peering_connection_id
|
|
39
41
|
connection = find_vpc_peering_connection(route.vpc_peering_connection_id)
|
|
40
|
-
|
|
42
|
+
if connection
|
|
43
|
+
linespecs.push(ERB.new(route_table_spec_connection_linetemplate, trim_mode: '-').result(binding))
|
|
44
|
+
end
|
|
41
45
|
end
|
|
42
46
|
if route.nat_gateway_id
|
|
43
|
-
linespecs.push(ERB.new(route_table_spec_nat_linetemplate,
|
|
47
|
+
linespecs.push(ERB.new(route_table_spec_nat_linetemplate, trim_mode: '-').result(binding))
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
linespecs
|
|
@@ -52,7 +56,7 @@ module Awspec::Generator
|
|
|
52
56
|
next if a.subnet_id.nil?
|
|
53
57
|
|
|
54
58
|
subnet = find_subnet(a.subnet_id)
|
|
55
|
-
linespecs.push(ERB.new(route_table_spec_subnet_linetemplate,
|
|
59
|
+
linespecs.push(ERB.new(route_table_spec_subnet_linetemplate, trim_mode: '-').result(binding)) if subnet
|
|
56
60
|
end
|
|
57
61
|
linespecs
|
|
58
62
|
end
|
|
@@ -24,7 +24,7 @@ module Awspec::Generator
|
|
|
24
24
|
|
|
25
25
|
linespecs = []
|
|
26
26
|
acl.grants.each do |grant|
|
|
27
|
-
linespecs.push(ERB.new(grant_linetemplate,
|
|
27
|
+
linespecs.push(ERB.new(grant_linetemplate, trim_mode: '-').result(binding))
|
|
28
28
|
end
|
|
29
29
|
linespecs
|
|
30
30
|
end
|
|
@@ -79,7 +79,7 @@ it do
|
|
|
79
79
|
)
|
|
80
80
|
end
|
|
81
81
|
EOF
|
|
82
|
-
linespecs.push(ERB.new(template,
|
|
82
|
+
linespecs.push(ERB.new(template, trim_mode: '-').result(binding))
|
|
83
83
|
end
|
|
84
84
|
linespecs
|
|
85
85
|
end
|
|
@@ -124,7 +124,7 @@ EOF
|
|
|
124
124
|
lifecycle_rule = find_bucket_lifecycle_configuration(bucket.name)
|
|
125
125
|
lifecycle_specs = generate_lifecycle_rule_specs(lifecycle_rule) if lifecycle_rule
|
|
126
126
|
location = find_bucket_location(bucket.name)
|
|
127
|
-
ERB.new(bucket_spec_template,
|
|
127
|
+
ERB.new(bucket_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -23,7 +23,7 @@ module Awspec::Generator
|
|
|
23
23
|
outbound_rule_count = sg[:ip_permissions_egress].reduce(0) do |sum, permission|
|
|
24
24
|
sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
|
|
25
25
|
end
|
|
26
|
-
content = ERB.new(security_group_spec_template,
|
|
26
|
+
content = ERB.new(security_group_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
27
27
|
end
|
|
28
28
|
specs.join("\n")
|
|
29
29
|
end
|
|
@@ -49,12 +49,12 @@ module Awspec::Generator
|
|
|
49
49
|
|
|
50
50
|
permission.ip_ranges.each do |ip_range|
|
|
51
51
|
target = ip_range.cidr_ip
|
|
52
|
-
linespecs.push(ERB.new(security_group_spec_linetemplate,
|
|
52
|
+
linespecs.push(ERB.new(security_group_spec_linetemplate, trim_mode: '-').result(binding))
|
|
53
53
|
end
|
|
54
54
|
permission.user_id_group_pairs.each do |group|
|
|
55
55
|
target = group.group_name
|
|
56
56
|
target = group.group_id unless group.group_name
|
|
57
|
-
linespecs.push(ERB.new(security_group_spec_linetemplate,
|
|
57
|
+
linespecs.push(ERB.new(security_group_spec_linetemplate, trim_mode: '-').result(binding))
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -17,7 +17,7 @@ module Awspec::Generator
|
|
|
17
17
|
specs = subnets.map do |subnet|
|
|
18
18
|
subnet_id = subnet[:subnet_id]
|
|
19
19
|
subnet_tag_name = subnet.tag_name
|
|
20
|
-
content = ERB.new(subnet_spec_template,
|
|
20
|
+
content = ERB.new(subnet_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
21
21
|
end
|
|
22
22
|
specs.join("\n")
|
|
23
23
|
end
|
|
@@ -16,7 +16,7 @@ module Awspec::Generator
|
|
|
16
16
|
route_tables = select_route_table_by_vpc_id(@vpc_id)
|
|
17
17
|
network_acls = select_network_acl_by_vpc_id(@vpc_id)
|
|
18
18
|
vpc_attributes = select_vpc_attribute(@vpc_id)
|
|
19
|
-
spec = ERB.new(vpc_spec_template,
|
|
19
|
+
spec = ERB.new(vpc_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# rubocop:disable all
|
|
@@ -10,7 +10,7 @@ module Awspec::Generator
|
|
|
10
10
|
|
|
11
11
|
specs = ip_sets.map do |i|
|
|
12
12
|
ip_set = get_ip_set(scope, i.name, i.id)
|
|
13
|
-
ERB.new(wafv2_ip_set_spec_template,
|
|
13
|
+
ERB.new(wafv2_ip_set_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
14
14
|
end
|
|
15
15
|
specs.join("\n")
|
|
16
16
|
end
|
|
@@ -10,7 +10,7 @@ module Awspec::Generator
|
|
|
10
10
|
|
|
11
11
|
specs = web_acls.map do |acl|
|
|
12
12
|
web_acl = get_web_acl(scope, acl.name, acl.id)
|
|
13
|
-
ERB.new(wafv2_web_acl_spec_template,
|
|
13
|
+
ERB.new(wafv2_web_acl_spec_template, trim_mode: '-').result(binding).gsub(/^\n/, '')
|
|
14
14
|
end
|
|
15
15
|
specs.join("\n")
|
|
16
16
|
end
|
|
@@ -67,6 +67,15 @@ module Awspec::Helper
|
|
|
67
67
|
nil
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
def select_backup_rule_by_plan_id(id)
|
|
71
|
+
selected = []
|
|
72
|
+
req = { backup_plan_id: id }
|
|
73
|
+
res = backup_client.get_backup_plan(req)
|
|
74
|
+
selected = res.backup_plan.rules
|
|
75
|
+
rescue Aws::Backup::Errors::ResourceNotFoundException
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
70
79
|
def locked?
|
|
71
80
|
resource_via_client.locked
|
|
72
81
|
end
|
|
@@ -23,7 +23,23 @@ module Awspec::Helper
|
|
|
23
23
|
)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
selected.single_resource(id)
|
|
26
|
+
res = selected.single_resource(id)
|
|
27
|
+
|
|
28
|
+
unless res.nil?
|
|
29
|
+
# Enrich the resource with all the fields returned by get_user, get_group, get_role, get_policy
|
|
30
|
+
params = type == 'policy' ? { :policy_arn => res['arn'] } : { "#{type}_name".to_sym => res["#{type}_name"] }
|
|
31
|
+
r = iam_client.send(
|
|
32
|
+
"get_#{type}",
|
|
33
|
+
params
|
|
34
|
+
)
|
|
35
|
+
object = r[type.to_sym]
|
|
36
|
+
unless object.nil?
|
|
37
|
+
object.to_h.each_key do |k|
|
|
38
|
+
res[k] = object[k] if res[k].nil?
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
res
|
|
27
43
|
end
|
|
28
44
|
end
|
|
29
45
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec::Matchers.define :have_plan_rule do |rule_id|
|
|
4
|
+
attr_list = %w[
|
|
5
|
+
rule_name target_backup_vault_name schedule_expression
|
|
6
|
+
start_window_minutes completion_window_minutes lifecycle
|
|
7
|
+
enable_continuous_backup schedule_expression_timezone
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
match do |plan|
|
|
11
|
+
plan.has_plan_rule?(rule_id,
|
|
12
|
+
rule_name: @rule_name,
|
|
13
|
+
target_backup_vault_name: @target_backup_vault_name,
|
|
14
|
+
schedule_expression: @schedule_expression,
|
|
15
|
+
start_window_minutes: @start_window_minutes,
|
|
16
|
+
completion_window_minutes: @completion_window_minutes,
|
|
17
|
+
lifecycle: @lifecycle,
|
|
18
|
+
enable_continuous_backup: @enable_continuous_backup,
|
|
19
|
+
schedule_expression_timezone: @schedule_expression_timezone)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
attr_list.each do |a|
|
|
23
|
+
define_method a.to_sym do |*args|
|
|
24
|
+
instance_variable_set("@#{a}", args[0])
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
description do
|
|
30
|
+
attr = ''
|
|
31
|
+
attr_list.each do |a|
|
|
32
|
+
attr += "#{a} #{instance_variable_get("@#{a}")}" unless instance_variable_get("@#{a}").nil?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
attr = " with #{attr}" if attr != ''
|
|
36
|
+
"have plan rule #{rule_id}#{attr}"
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/awspec/matcher.rb
CHANGED
|
@@ -28,6 +28,44 @@ Aws.config[:backup] = {
|
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
30
|
next_token: nil
|
|
31
|
+
},
|
|
32
|
+
get_backup_plan: {
|
|
33
|
+
backup_plan: {
|
|
34
|
+
backup_plan_name: 'my-backup-plan',
|
|
35
|
+
rules: [
|
|
36
|
+
{
|
|
37
|
+
rule_name: 'my-daily-backup',
|
|
38
|
+
target_backup_vault_name: 'my-backup-vault',
|
|
39
|
+
schedule_expression: 'cron(0 0 * * ? *)',
|
|
40
|
+
start_window_minutes: 360,
|
|
41
|
+
completion_window_minutes: 1440,
|
|
42
|
+
lifecycle: {
|
|
43
|
+
delete_after_days: 7
|
|
44
|
+
},
|
|
45
|
+
rule_id: '8dd6ef67-9eeb-4743-98be-5b4c582ee3d0',
|
|
46
|
+
enable_continuous_backup: false,
|
|
47
|
+
schedule_expression_timezone: 'Etc/UTC'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
rule_name: 'backup-rule-hourly-30-days',
|
|
51
|
+
target_backup_vault_name: 'Default',
|
|
52
|
+
schedule_expression: 'cron(30 * ? * * *)',
|
|
53
|
+
start_window_minutes: 60,
|
|
54
|
+
completion_window_minutes: 1440,
|
|
55
|
+
lifecycle: {
|
|
56
|
+
delete_after_days: 30
|
|
57
|
+
},
|
|
58
|
+
rule_id: 'febe7fd4-c95f-4d26-b502-97adf2fd0cf4',
|
|
59
|
+
enable_continuous_backup: false,
|
|
60
|
+
schedule_expression_timezone: 'Etc/UTC'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
backup_plan_id: 'fff3e784-1a0f-4e7c-8fe9-ba69825f7c00',
|
|
65
|
+
backup_plan_arn: 'arn:aws:backup:us-west-2:111122223333:backup-plan:fff3e784-1a0f-4e7c-8fe9-ba69825f7c00',
|
|
66
|
+
version_id: 'disFW7K0dOAjTaMWKYlhEyScjBhmi5kKGf7BrY7i1BG8F8wB',
|
|
67
|
+
creation_date: Time.new(2016, 10, 4, 9, 00, 00, '+00:00'),
|
|
68
|
+
last_execution_date: Time.new(2025, 10, 4, 9, 00, 00, '+00:00')
|
|
31
69
|
}
|
|
32
70
|
}
|
|
33
71
|
}
|
|
@@ -33,7 +33,7 @@ Aws.config[:iam] = {
|
|
|
33
33
|
policies: [
|
|
34
34
|
{
|
|
35
35
|
attachment_count: 1,
|
|
36
|
-
arn: 'arn:aws:iam::
|
|
36
|
+
arn: 'arn:aws:iam::123456789012:policy/my-iam-policy',
|
|
37
37
|
default_version_id: 'v1',
|
|
38
38
|
is_attachable: true,
|
|
39
39
|
policy_id: 'PABCDEFGHI123455689',
|
|
@@ -81,6 +81,20 @@ Aws.config[:iam] = {
|
|
|
81
81
|
is_default_version: true,
|
|
82
82
|
create_date: Time.new(2022, 11, 12, 01, 23, 45, '+00:00')
|
|
83
83
|
}
|
|
84
|
+
},
|
|
85
|
+
get_policy: {
|
|
86
|
+
policy: {
|
|
87
|
+
policy_name: 'my-iam-policy',
|
|
88
|
+
create_date: Time.new(2014, 1, 2, 10, 00, 00, '+00:00'),
|
|
89
|
+
description: 'my-description',
|
|
90
|
+
attachment_count: 1,
|
|
91
|
+
is_attachable: true,
|
|
92
|
+
policy_id: 'PABCDEFGHI123455689',
|
|
93
|
+
default_version_id: 'v1',
|
|
94
|
+
path: '/',
|
|
95
|
+
arn: 'arn:aws:iam::123456789012:policy/my-iam-policy',
|
|
96
|
+
update_date: Time.new(2015, 1, 2, 10, 00, 00, '+00:00')
|
|
97
|
+
}
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
100
|
}
|
data/lib/awspec/stub/iam_role.rb
CHANGED
|
@@ -8,6 +8,7 @@ Aws.config[:iam] = {
|
|
|
8
8
|
role_name: 'my-iam-role',
|
|
9
9
|
role_id: 'RABCDEFGHI123455689',
|
|
10
10
|
arn: 'arn:aws:iam::123456789012:role/my-iam-role',
|
|
11
|
+
description: 'my-description',
|
|
11
12
|
create_date: Time.new(2015, 1, 2, 9, 00, 00, '+00:00')
|
|
12
13
|
]
|
|
13
14
|
},
|
|
@@ -34,7 +35,16 @@ Aws.config[:iam] = {
|
|
|
34
35
|
role_name: 'my-iam-role',
|
|
35
36
|
role_id: 'RABCDEFGHI123455689',
|
|
36
37
|
arn: 'arn:aws:iam::123456789012:role/my-iam-role',
|
|
37
|
-
|
|
38
|
+
description: 'my-description',
|
|
39
|
+
create_date: Time.new(2015, 1, 2, 9, 00, 00, '+00:00'),
|
|
40
|
+
permissions_boundary: {
|
|
41
|
+
permissions_boundary_type: 'Policy',
|
|
42
|
+
permissions_boundary_arn: 'arn:aws:iam::123456789012:policy/my-permission-boundary'
|
|
43
|
+
},
|
|
44
|
+
role_last_used: {
|
|
45
|
+
region: 'us-east-1',
|
|
46
|
+
last_used_date: Time.new(2019, 11, 13, 17, 14, 00, '+00:00')
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
},
|
|
40
50
|
get_role_policy: {
|
|
@@ -9,5 +9,45 @@ module Awspec::Type
|
|
|
9
9
|
def id
|
|
10
10
|
@id ||= resource_via_client.backup_plan_id if resource_via_client
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
|
14
|
+
def has_plan_rule?(rule_id,
|
|
15
|
+
rule_name: nil,
|
|
16
|
+
target_backup_vault_name: nil,
|
|
17
|
+
schedule_expression: nil,
|
|
18
|
+
start_window_minutes: nil,
|
|
19
|
+
completion_window_minutes: nil,
|
|
20
|
+
lifecycle: nil,
|
|
21
|
+
enable_continuous_backup: nil,
|
|
22
|
+
schedule_expression_timezone: nil)
|
|
23
|
+
rules = select_backup_rule_by_plan_id(resource_via_client.backup_plan_id)
|
|
24
|
+
rules.find do |rule|
|
|
25
|
+
next false if !rule_id.nil? && rule.rule_id != rule_id && rule.rule_name != rule_id
|
|
26
|
+
next false if !rule_name.nil? && rule.rule_name != rule_name
|
|
27
|
+
next false if !target_backup_vault_name.nil? && rule.target_backup_vault_name != target_backup_vault_name
|
|
28
|
+
next false if !schedule_expression.nil? && rule.schedule_expression != schedule_expression
|
|
29
|
+
next false if !start_window_minutes.nil? && rule.start_window_minutes != start_window_minutes
|
|
30
|
+
next false if !completion_window_minutes.nil? && rule.completion_window_minutes != completion_window_minutes
|
|
31
|
+
next false if !enable_continuous_backup.nil? && rule.enable_continuous_backup != enable_continuous_backup
|
|
32
|
+
next false if !schedule_expression_timezone.nil? && \
|
|
33
|
+
rule.schedule_expression_timezone != schedule_expression_timezone
|
|
34
|
+
next false if !lifecycle.nil? && !_lifecycle_is_equal?(rule.lifecycle, lifecycle)
|
|
35
|
+
|
|
36
|
+
true
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def _lifecycle_is_equal?(lc1, lc2)
|
|
43
|
+
lc2_j = JSON.parse lc2
|
|
44
|
+
ret = false
|
|
45
|
+
%w[move_to_cold_storage_after_days delete_after_days opt_in_to_archive_for_supported_resources].each do |attr|
|
|
46
|
+
ret = true if !lc1[attr].nil? && lc2.include?(attr) && lc1[attr].to_s.strip == lc2_j[attr].to_s.strip
|
|
47
|
+
end
|
|
48
|
+
ret
|
|
49
|
+
rescue JSON::ParserError
|
|
50
|
+
raise ArgumentError, "Lifecycle value '#{lc2}' is not valid JSON"
|
|
51
|
+
end
|
|
12
52
|
end
|
|
13
53
|
end
|
data/lib/awspec/version.rb
CHANGED