awspec 1.32.0 → 1.34.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/release.yml +4 -0
  3. data/.github/workflows/ci.yml +7 -7
  4. data/.github/workflows/doc.yml +4 -4
  5. data/.github/workflows/tagpr.yml +58 -0
  6. data/.rubocop.yml +1 -0
  7. data/.tagpr +35 -0
  8. data/CHANGELOG.md +98 -0
  9. data/doc/_resource_types/backup_plan.md +7 -0
  10. data/doc/_resource_types/backup_selection.md +7 -0
  11. data/doc/_resource_types/backup_vault.md +35 -0
  12. data/doc/_resource_types/rds_db_cluster.md +8 -0
  13. data/doc/_resource_types/rds_global_cluster.md +8 -0
  14. data/doc/_resource_types/transfer_server.md +4 -0
  15. data/doc/_resource_types/wafv2_ip_set.md +6 -2
  16. data/doc/_resource_types/wafv2_web_acl.md +25 -0
  17. data/doc/contributing.md +2 -2
  18. data/doc/resource_types.md +131 -33
  19. data/lib/awspec/generator/doc/type/backup_plan.rb +19 -0
  20. data/lib/awspec/generator/doc/type/backup_selection.rb +19 -0
  21. data/lib/awspec/generator/doc/type/backup_vault.rb +19 -0
  22. data/lib/awspec/generator/doc/type/wafv2_ip_set.rb +1 -1
  23. data/lib/awspec/generator/doc/type/wafv2_web_acl.rb +19 -0
  24. data/lib/awspec/generator/spec/wafv2_web_acl.rb +39 -0
  25. data/lib/awspec/generator.rb +1 -0
  26. data/lib/awspec/helper/finder/backup.rb +97 -0
  27. data/lib/awspec/helper/finder/transfer.rb +21 -1
  28. data/lib/awspec/helper/finder/wafv2.rb +20 -0
  29. data/lib/awspec/helper/finder.rb +4 -1
  30. data/lib/awspec/helper/type.rb +2 -1
  31. data/lib/awspec/matcher/belong_to_backup_plan.rb +12 -0
  32. data/lib/awspec/matcher/have_plan_rule.rb +47 -0
  33. data/lib/awspec/matcher/have_rule.rb +5 -0
  34. data/lib/awspec/matcher.rb +6 -0
  35. data/lib/awspec/stub/backup_plan.rb +71 -0
  36. data/lib/awspec/stub/backup_selection.rb +33 -0
  37. data/lib/awspec/stub/backup_vault.rb +53 -0
  38. data/lib/awspec/stub/rds_db_cluster.rb +6 -1
  39. data/lib/awspec/stub/rds_global_cluster.rb +7 -1
  40. data/lib/awspec/stub/transfer_server.rb +25 -6
  41. data/lib/awspec/stub/wafv2_ip_set.rb +7 -5
  42. data/lib/awspec/stub/wafv2_web_acl.rb +151 -0
  43. data/lib/awspec/type/backup_plan.rb +53 -0
  44. data/lib/awspec/type/backup_selection.rb +13 -0
  45. data/lib/awspec/type/backup_vault.rb +13 -0
  46. data/lib/awspec/type/base.rb +5 -1
  47. data/lib/awspec/type/codepipeline.rb +1 -1
  48. data/lib/awspec/type/rds_db_cluster.rb +1 -0
  49. data/lib/awspec/type/rds_global_cluster.rb +1 -0
  50. data/lib/awspec/type/transfer_server.rb +4 -7
  51. data/lib/awspec/type/wafv2_web_acl.rb +33 -0
  52. data/lib/awspec/version.rb +1 -1
  53. metadata +27 -3
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+
3
+ Aws.config[:wafv2] = {
4
+ stub_responses: {
5
+ get_web_acl: {
6
+ web_acl: {
7
+ name: 'my-wafv2-web-acl',
8
+ id: 'a64cc988-40ec-4c4e-ab80-c9acbea42103',
9
+ arn: 'arn:aws:wafv2:ap-northeast-1:123456789012:regional/webacl/'\
10
+ 'my-wafv2-web-acl/a64cc988-40ec-4c4e-ab80-c9acbea42103',
11
+ default_action: {
12
+ allow: {}
13
+ },
14
+ description: 'test web acl',
15
+ rules: [
16
+ {
17
+ name: 'AWS-AWSManagedRulesCommonRuleSet',
18
+ priority: 0,
19
+ statement: {
20
+ managed_rule_group_statement: {
21
+ vendor_name: 'AWS',
22
+ name: 'AWSManagedRulesCommonRuleSet'
23
+ }
24
+ },
25
+ override_action: {
26
+ none: {}
27
+ },
28
+ visibility_config: {
29
+ sampled_requests_enabled: true,
30
+ cloud_watch_metrics_enabled: true,
31
+ metric_name: 'AWS-AWSManagedRulesCommonRuleSet'
32
+ }
33
+ },
34
+ {
35
+ name: 'AWS-AWSManagedRulesKnownBadInputsRuleSet',
36
+ priority: 1,
37
+ statement: {
38
+ managed_rule_group_statement: {
39
+ vendor_name: 'AWS',
40
+ name: 'AWSManagedRulesKnownBadInputsRuleSet'
41
+ }
42
+ },
43
+ override_action: {
44
+ none: {}
45
+ },
46
+ visibility_config: {
47
+ sampled_requests_enabled: true,
48
+ cloud_watch_metrics_enabled: true,
49
+ metric_name: 'AWS-AWSManagedRulesKnownBadInputsRuleSet'
50
+ }
51
+ },
52
+ {
53
+ name: 'AWS-AWSManagedRulesLinuxRuleSet',
54
+ priority: 2,
55
+ statement: {
56
+ managed_rule_group_statement: {
57
+ vendor_name: 'AWS',
58
+ name: 'AWSManagedRulesLinuxRuleSet'
59
+ }
60
+ },
61
+ override_action: {
62
+ none: {}
63
+ },
64
+ visibility_config: {
65
+ sampled_requests_enabled: true,
66
+ cloud_watch_metrics_enabled: true,
67
+ metric_name: 'AWS-AWSManagedRulesLinuxRuleSet'
68
+ }
69
+ },
70
+ {
71
+ name: 'AWS-AWSManagedRulesUnixRuleSet',
72
+ priority: 3,
73
+ statement: {
74
+ managed_rule_group_statement: {
75
+ vendor_name: 'AWS',
76
+ name: 'AWSManagedRulesUnixRuleSet'
77
+ }
78
+ },
79
+ override_action: {
80
+ none: {}
81
+ },
82
+ visibility_config: {
83
+ sampled_requests_enabled: true,
84
+ cloud_watch_metrics_enabled: true,
85
+ metric_name: 'AWS-AWSManagedRulesUnixRuleSet'
86
+ }
87
+ },
88
+ {
89
+ name: 'AWS-AWSManagedRulesAnonymousIpList',
90
+ priority: 4,
91
+ statement: {
92
+ managed_rule_group_statement: {
93
+ vendor_name: 'AWS',
94
+ name: 'AWSManagedRulesAnonymousIpList'
95
+ }
96
+ },
97
+ override_action: {
98
+ none: {}
99
+ },
100
+ visibility_config: {
101
+ sampled_requests_enabled: true,
102
+ cloud_watch_metrics_enabled: true,
103
+ metric_name: 'AWS-AWSManagedRulesAnonymousIpList'
104
+ }
105
+ },
106
+ {
107
+ name: 'AWS-AWSManagedRulesAmazonIpReputationList',
108
+ priority: 5,
109
+ statement: {
110
+ managed_rule_group_statement: {
111
+ vendor_name: 'AWS',
112
+ name: 'AWSManagedRulesAmazonIpReputationList'
113
+ }
114
+ },
115
+ override_action: {
116
+ none: {}
117
+ },
118
+ visibility_config: {
119
+ sampled_requests_enabled: true,
120
+ cloud_watch_metrics_enabled: true,
121
+ metric_name: 'AWS-AWSManagedRulesAmazonIpReputationList'
122
+ }
123
+ }
124
+ ],
125
+ visibility_config: {
126
+ sampled_requests_enabled: true,
127
+ cloud_watch_metrics_enabled: true,
128
+ metric_name: 'my-wafv2-web-acl'
129
+ },
130
+ capacity: 1275,
131
+ managed_by_firewall_manager: false,
132
+ label_namespace: 'awswaf:123456789012:webacl:my-wafv2-web-acl:',
133
+ retrofitted_by_firewall_manager: false
134
+ },
135
+ 'lock_token': '8060f9d3-6437-4457-934c-e20bc0440e04'
136
+ },
137
+ list_web_acls: {
138
+ next_marker: 'my-wafv2-web-acl',
139
+ web_acls: [
140
+ {
141
+ name: 'my-wafv2-web-acl',
142
+ id: 'a64cc988-40ec-4c4e-ab80-c9acbea42103',
143
+ description: '',
144
+ lock_token: '8060f9d3-6437-4457-934c-e20bc0440e04',
145
+ arn: 'arn:aws:wafv2:ap-northeast-1:123456789012:regional/webacl/'\
146
+ 'my-wafv2-web-acl/a64cc988-40ec-4c4e-ab80-c9acbea42103'
147
+ }
148
+ ]
149
+ }
150
+ }
151
+ }
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class BackupPlan < ResourceBase
5
+ def resource_via_client
6
+ @resource_via_client ||= find_backup_plan(@display_name)
7
+ end
8
+
9
+ def id
10
+ @id ||= resource_via_client.backup_plan_id if resource_via_client
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
52
+ end
53
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class BackupSelection < ResourceBase
5
+ def resource_via_client
6
+ @resource_via_client ||= find_backup_selection(@display_name)
7
+ end
8
+
9
+ def id
10
+ @id ||= resource_via_client.selection_id if resource_via_client
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class BackupVault < ResourceBase
5
+ def resource_via_client
6
+ @resource_via_client ||= find_backup_vault(@display_name)
7
+ end
8
+
9
+ def id
10
+ @id ||= resource_via_client.backup_vault_arn if resource_via_client
11
+ end
12
+ end
13
+ end
@@ -33,7 +33,11 @@ module Awspec::Type
33
33
  begin
34
34
  tags = resource_via_client.tags
35
35
  rescue NoMethodError
36
- tags = resource_via_client.tag_set
36
+ begin
37
+ tags = resource_via_client.tag_set
38
+ rescue NoMethodError
39
+ tags = resource_via_client.tag_list
40
+ end
37
41
  end
38
42
  return false unless tags
39
43
 
@@ -7,7 +7,7 @@ module Awspec::Type
7
7
  end
8
8
 
9
9
  def id
10
- @id ||= resource_via_client if resource_via_client.name
10
+ @id ||= resource_via_client.name if resource_via_client
11
11
  end
12
12
  end
13
13
  end
@@ -3,6 +3,7 @@
3
3
  module Awspec::Type
4
4
  class RdsDBCluster < ResourceBase
5
5
  aws_resource Aws::RDS::Types::DBCluster
6
+ tags_allowed
6
7
 
7
8
  def resource_via_client
8
9
  @resource_via_client ||= find_db_cluster(@display_name)
@@ -3,6 +3,7 @@
3
3
  module Awspec::Type
4
4
  class RdsGlobalCluster < ResourceBase
5
5
  aws_resource Aws::RDS::Types::GlobalCluster
6
+ tags_allowed
6
7
 
7
8
  def resource_via_client
8
9
  @resource_via_client ||= find_global_cluster(@display_name)
@@ -2,17 +2,14 @@
2
2
 
3
3
  module Awspec::Type
4
4
  class TransferServer < ResourceBase
5
- attr_reader :id
6
-
7
5
  tags_allowed
8
6
 
9
- def initialize(id)
10
- super
11
- @id = id
7
+ def resource_via_client
8
+ @resource_via_client ||= find_transfer_server(@display_name)
12
9
  end
13
10
 
14
- def resource_via_client
15
- @resource_via_client ||= find_transfer_server(@id)
11
+ def id
12
+ @id ||= resource_via_client.server_id if resource_via_client
16
13
  end
17
14
 
18
15
  STATES = %w[
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class Wafv2WebAcl < ResourceBase
5
+ attr_accessor :scope
6
+
7
+ def resource_via_client
8
+ @resource_via_client ||= find_web_acl(scope, @display_name)
9
+ end
10
+
11
+ def id
12
+ @id ||= resource_via_client.id if resource_via_client
13
+ end
14
+
15
+ def scope
16
+ @scope || 'REGIONAL'
17
+ end
18
+
19
+ def default_action
20
+ resource_via_client.default_action.allow ? 'ALLOW' : 'BLOCK'
21
+ end
22
+
23
+ def has_rule?(name, priority = nil, action = nil, override_action = nil)
24
+ resource_via_client.rules.find do |rule|
25
+ next false if !priority.nil? && rule.priority != priority
26
+ next false if !action.nil? && !rule.action.reject { |v| v.nil? }.first.class.to_s.include?(action.capitalize)
27
+ next false if !override_action.nil? &&
28
+ !rule.override_action.reject { |v| v.nil? }.first.class.to_s.include?(override_action.capitalize)
29
+ next true if rule.name == name
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Awspec
4
- VERSION = '1.32.0'
4
+ VERSION = '1.34.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.32.0
4
+ version: 1.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: addressable
@@ -262,9 +262,13 @@ extensions: []
262
262
  extra_rdoc_files: []
263
263
  files:
264
264
  - ".editorconfig"
265
+ - ".github/release.yml"
265
266
  - ".github/workflows/ci.yml"
266
267
  - ".github/workflows/doc.yml"
268
+ - ".github/workflows/tagpr.yml"
267
269
  - ".rubocop.yml"
270
+ - ".tagpr"
271
+ - CHANGELOG.md
268
272
  - Gemfile
269
273
  - LICENSE.txt
270
274
  - README.md
@@ -281,6 +285,9 @@ files:
281
285
  - doc/_resource_types/ami.md
282
286
  - doc/_resource_types/apigateway.md
283
287
  - doc/_resource_types/autoscaling_group.md
288
+ - doc/_resource_types/backup_plan.md
289
+ - doc/_resource_types/backup_selection.md
290
+ - doc/_resource_types/backup_vault.md
284
291
  - doc/_resource_types/batch_compute_environment.md
285
292
  - doc/_resource_types/batch_job_definition.md
286
293
  - doc/_resource_types/batch_job_queue.md
@@ -367,6 +374,7 @@ files:
367
374
  - doc/_resource_types/waf_web_acl.md
368
375
  - doc/_resource_types/wafregional_web_acl.md
369
376
  - doc/_resource_types/wafv2_ip_set.md
377
+ - doc/_resource_types/wafv2_web_acl.md
370
378
  - doc/contributing.md
371
379
  - doc/resource_types.md
372
380
  - exe/awspec
@@ -392,6 +400,9 @@ files:
392
400
  - lib/awspec/generator/doc/type/ami.rb
393
401
  - lib/awspec/generator/doc/type/apigateway.rb
394
402
  - lib/awspec/generator/doc/type/autoscaling_group.rb
403
+ - lib/awspec/generator/doc/type/backup_plan.rb
404
+ - lib/awspec/generator/doc/type/backup_selection.rb
405
+ - lib/awspec/generator/doc/type/backup_vault.rb
395
406
  - lib/awspec/generator/doc/type/base.rb
396
407
  - lib/awspec/generator/doc/type/batch_compute_environment.rb
397
408
  - lib/awspec/generator/doc/type/batch_job_definition.rb
@@ -480,6 +491,7 @@ files:
480
491
  - lib/awspec/generator/doc/type/waf_web_acl.rb
481
492
  - lib/awspec/generator/doc/type/wafregional_web_acl.rb
482
493
  - lib/awspec/generator/doc/type/wafv2_ip_set.rb
494
+ - lib/awspec/generator/doc/type/wafv2_web_acl.rb
483
495
  - lib/awspec/generator/spec/acm.rb
484
496
  - lib/awspec/generator/spec/alb.rb
485
497
  - lib/awspec/generator/spec/alb_listener.rb
@@ -525,6 +537,7 @@ files:
525
537
  - lib/awspec/generator/spec/subnet.rb
526
538
  - lib/awspec/generator/spec/vpc.rb
527
539
  - lib/awspec/generator/spec/wafv2_ip_set.rb
540
+ - lib/awspec/generator/spec/wafv2_web_acl.rb
528
541
  - lib/awspec/generator/template.rb
529
542
  - lib/awspec/helper.rb
530
543
  - lib/awspec/helper/client_wrap.rb
@@ -536,6 +549,7 @@ files:
536
549
  - lib/awspec/helper/finder/ami.rb
537
550
  - lib/awspec/helper/finder/apigateway.rb
538
551
  - lib/awspec/helper/finder/autoscaling.rb
552
+ - lib/awspec/helper/finder/backup.rb
539
553
  - lib/awspec/helper/finder/batch.rb
540
554
  - lib/awspec/helper/finder/cloudformation.rb
541
555
  - lib/awspec/helper/finder/cloudfront.rb
@@ -598,6 +612,7 @@ files:
598
612
  - lib/awspec/matcher/be_opened.rb
599
613
  - lib/awspec/matcher/be_opened_only.rb
600
614
  - lib/awspec/matcher/belong_to_alb.rb
615
+ - lib/awspec/matcher/belong_to_backup_plan.rb
601
616
  - lib/awspec/matcher/belong_to_cache_subnet_group.rb
602
617
  - lib/awspec/matcher/belong_to_cluster_subnet_group.rb
603
618
  - lib/awspec/matcher/belong_to_db_subnet_group.rb
@@ -625,6 +640,7 @@ files:
625
640
  - lib/awspec/matcher/have_network_interface.rb
626
641
  - lib/awspec/matcher/have_option_group.rb
627
642
  - lib/awspec/matcher/have_origin.rb
643
+ - lib/awspec/matcher/have_plan_rule.rb
628
644
  - lib/awspec/matcher/have_private_ip_address.rb
629
645
  - lib/awspec/matcher/have_record_set.rb
630
646
  - lib/awspec/matcher/have_route.rb
@@ -646,6 +662,9 @@ files:
646
662
  - lib/awspec/stub/ami.rb
647
663
  - lib/awspec/stub/apigateway.rb
648
664
  - lib/awspec/stub/autoscaling_group.rb
665
+ - lib/awspec/stub/backup_plan.rb
666
+ - lib/awspec/stub/backup_selection.rb
667
+ - lib/awspec/stub/backup_vault.rb
649
668
  - lib/awspec/stub/batch_compute_environment.rb
650
669
  - lib/awspec/stub/batch_job_definition.rb
651
670
  - lib/awspec/stub/batch_job_queue.rb
@@ -734,6 +753,7 @@ files:
734
753
  - lib/awspec/stub/waf_web_acl.rb
735
754
  - lib/awspec/stub/wafregional_web_acl.rb
736
755
  - lib/awspec/stub/wafv2_ip_set.rb
756
+ - lib/awspec/stub/wafv2_web_acl.rb
737
757
  - lib/awspec/toolbox.rb
738
758
  - lib/awspec/type/account.rb
739
759
  - lib/awspec/type/account_attribute.rb
@@ -745,6 +765,9 @@ files:
745
765
  - lib/awspec/type/ami.rb
746
766
  - lib/awspec/type/apigateway.rb
747
767
  - lib/awspec/type/autoscaling_group.rb
768
+ - lib/awspec/type/backup_plan.rb
769
+ - lib/awspec/type/backup_selection.rb
770
+ - lib/awspec/type/backup_vault.rb
748
771
  - lib/awspec/type/base.rb
749
772
  - lib/awspec/type/batch_compute_environment.rb
750
773
  - lib/awspec/type/batch_job_definition.rb
@@ -834,6 +857,7 @@ files:
834
857
  - lib/awspec/type/waf_web_acl.rb
835
858
  - lib/awspec/type/wafregional_web_acl.rb
836
859
  - lib/awspec/type/wafv2_ip_set.rb
860
+ - lib/awspec/type/wafv2_web_acl.rb
837
861
  - lib/awspec/version.rb
838
862
  homepage: https://github.com/k1LoW/awspec
839
863
  licenses:
@@ -853,7 +877,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
853
877
  - !ruby/object:Gem::Version
854
878
  version: '0'
855
879
  requirements: []
856
- rubygems_version: 3.6.2
880
+ rubygems_version: 3.6.9
857
881
  specification_version: 4
858
882
  summary: RSpec tests for your AWS resources.
859
883
  test_files: []