awspec 1.27.1 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e438eb5cfb3e76e33ccfe2fb709db146f8334316d7ff7784b0d5286e94bee9f
4
- data.tar.gz: 7f6e39251c505d268168172fea2f87e7faa2e255dbf98169df16445a97e079b4
3
+ metadata.gz: a7d1b88af80d3b1bf908f34ad1f537505881bfb258f88ff56db14ab63d37afb8
4
+ data.tar.gz: 4da3943ff6e94748d3816823e91134d58a9a7ee522159534c1728ac0dbdc3afb
5
5
  SHA512:
6
- metadata.gz: c919af8b30166ab362c1e8b3381f215c79ae6fd5498cd32ef1863e4d11505ea4e5992e781a1f483bede011fc9c0a91b898c4ac72ffc0eaa50c1bc44f8910206d
7
- data.tar.gz: 6c21d9579d80a52ad797f1b54318fb3ded718ffa9718831cdcd5cfb7c2aacb4c1459385f4b315fba6a0182a51b049d7d989824a9026d469e4e15fa94ab8bc27b
6
+ metadata.gz: 4dd50e4e4c5d3c3afb5a2c8c45de378fcc8b90bdf3cd0f2d8e47e951713d4022d084621a47fc0c32853cfa86ebec335a6e302acc8cb35513d240ecb2d56de1e4
7
+ data.tar.gz: ed8efb4183559c1ac70c8b801e2545a9fff732c2584f9fb34b2878e5275a0ba91a1fcafd9be469f33f78bbe2143a2f2555e433ea6be7b9d90ed9015bf103c7d1
@@ -0,0 +1,47 @@
1
+ ### first
2
+
3
+ ```ruby
4
+ describe rds_db_cluster('my-rds-db-cluster') do
5
+ its(:db_cluster_parameter_group) { should eq 'default.aurora-mysql5.7' }
6
+ its(:engine) { should eq 'aurora-mysql' }
7
+ its(:engine_version) { should eq '5.7.mysql_aurora.2.10.2' }
8
+ its(:database_name) { should eq 'example_db' }
9
+ its(:storage_encrypted) { should eq false }
10
+ its(:deletion_protection) { should eq false }
11
+ end
12
+ ```
13
+
14
+ ### exist
15
+
16
+ ```ruby
17
+ describe rds_db_cluster('my-rds-db-cluster') do
18
+ it { should exist }
19
+ end
20
+ ```
21
+
22
+ ### be_available, be_creating, be_deleting
23
+
24
+ ```ruby
25
+ describe rds_db_cluster('my-rds-db-cluster') do
26
+ it { should be_available }
27
+ end
28
+ ```
29
+
30
+ ### have_cluster_member
31
+
32
+ ```ruby
33
+ describe rds_db_cluster('my-rds-db-cluster') do
34
+ it { should have_cluster_member('my-rds-db-cluster-instance-1') }
35
+ it { should have_cluster_member('my-rds-db-cluster-instance-1').is_writer(true) }
36
+ it { should have_cluster_member('my-rds-db-cluster-instance-2').is_writer(false) }
37
+ end
38
+ ```
39
+
40
+ ### have_security_group
41
+
42
+ ```ruby
43
+ describe rds_db_cluster('my-rds-db-cluster') do
44
+ it { should have_security_group('sg-5a6b7cd8') }
45
+ it { should have_security_group('my-db-sg') }
46
+ end
47
+ ```
@@ -0,0 +1,25 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### belong_to_subnet
10
+
11
+ ```ruby
12
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
13
+ it { should belong_to_subnet('subnet-1234a567') }
14
+ it { should belong_to_subnet('db-subnet-a') }
15
+ end
16
+ ```
17
+
18
+ ### belong_to_vpc
19
+
20
+ ```ruby
21
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
22
+ it { should belong_to_vpc('vpc-ab123cde') }
23
+ it { should belong_to_vpc('my-vpc') }
24
+ end
25
+ ```
@@ -0,0 +1,37 @@
1
+ ### first
2
+
3
+ ```ruby
4
+ describe rds_global_cluster('my-rds-global-cluster') do
5
+ its(:engine) { should eq 'aurora-mysql' }
6
+ its(:engine_version) { should eq '5.7.mysql_aurora.2.10.2' }
7
+ its(:database_name) { should eq 'example_db' }
8
+ its(:storage_encrypted) { should eq false }
9
+ its(:deletion_protection) { should eq false }
10
+ end
11
+ ```
12
+
13
+ ### exist
14
+
15
+ ```ruby
16
+ describe rds_global_cluster('my-rds-global-cluster') do
17
+ it { should exist }
18
+ end
19
+ ```
20
+
21
+ ### be_available, be_creating, be_deleting
22
+
23
+ ```ruby
24
+ describe rds_global_cluster('my-rds-global-cluster') do
25
+ it { should be_available }
26
+ end
27
+ ```
28
+
29
+ ### have_cluster_member
30
+
31
+ ```ruby
32
+ describe rds_global_cluster('my-rds-global-cluster') do
33
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-1:123456789012:cluster:my-primary-cluster') }
34
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-1:123456789012:cluster:my-primary-cluster').is_writer(true) }
35
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-3:123456789012:cluster:my-secondary-cluster').is_writer(false) }
36
+ end
37
+ ```
@@ -61,8 +61,11 @@
61
61
  | [nlb_listener](#nlb_listener)
62
62
  | [nlb_target_group](#nlb_target_group)
63
63
  | [rds](#rds)
64
+ | [rds_db_cluster](#rds_db_cluster)
64
65
  | [rds_db_cluster_parameter_group](#rds_db_cluster_parameter_group)
65
66
  | [rds_db_parameter_group](#rds_db_parameter_group)
67
+ | [rds_db_subnet_group](#rds_db_subnet_group)
68
+ | [rds_global_cluster](#rds_global_cluster)
66
69
  | [rds_proxy](#rds_proxy)
67
70
  | [redshift](#redshift)
68
71
  | [redshift_cluster_parameter_group](#redshift_cluster_parameter_group)
@@ -2856,7 +2859,7 @@ end
2856
2859
  ```
2857
2860
 
2858
2861
 
2859
- ### its(:vpc_id), its(:db_instance_identifier), its(:db_instance_class), its(:engine), its(:db_instance_status), its(:automatic_restart_time), its(:master_username), its(:db_name), its(:endpoint), its(:allocated_storage), its(:instance_create_time), its(:preferred_backup_window), its(:backup_retention_period), its(:db_security_groups), its(:availability_zone), its(:preferred_maintenance_window), its(:pending_modified_values), its(:latest_restorable_time), its(:multi_az), its(:engine_version), its(:auto_minor_version_upgrade), its(:read_replica_source_db_instance_identifier), its(:read_replica_db_instance_identifiers), its(:read_replica_db_cluster_identifiers), its(:replica_mode), its(:license_model), its(:iops), its(:character_set_name), its(:nchar_character_set_name), its(:secondary_availability_zone), its(:publicly_accessible), its(:status_infos), its(:storage_type), its(:tde_credential_arn), its(:db_instance_port), its(:db_cluster_identifier), its(:storage_encrypted), its(:kms_key_id), its(:dbi_resource_id), its(:ca_certificate_identifier), its(:domain_memberships), its(:copy_tags_to_snapshot), its(:monitoring_interval), its(:enhanced_monitoring_resource_arn), its(:monitoring_role_arn), its(:promotion_tier), its(:db_instance_arn), its(:timezone), its(:iam_database_authentication_enabled), its(:performance_insights_enabled), its(:performance_insights_kms_key_id), its(:performance_insights_retention_period), its(:enabled_cloudwatch_logs_exports), its(:processor_features), its(:deletion_protection), its(:associated_roles), its(:listener_endpoint), its(:max_allocated_storage), its(:tag_list), its(:db_instance_automated_backups_replications), its(:customer_owned_ip_enabled), its(:aws_backup_recovery_point_arn), its(:activity_stream_status), its(:activity_stream_kms_key_id), its(:activity_stream_kinesis_stream_name), its(:activity_stream_mode), its(:activity_stream_engine_native_audit_fields_included), its(:automation_mode), its(:resume_full_automation_mode_time), its(:custom_iam_instance_profile), its(:backup_target), its(:network_type)
2862
+ ### its(:vpc_id), its(:db_instance_identifier), its(:db_instance_class), its(:engine), its(:db_instance_status), its(:automatic_restart_time), its(:master_username), its(:db_name), its(:endpoint), its(:allocated_storage), its(:instance_create_time), its(:preferred_backup_window), its(:backup_retention_period), its(:db_security_groups), its(:availability_zone), its(:preferred_maintenance_window), its(:pending_modified_values), its(:latest_restorable_time), its(:multi_az), its(:engine_version), its(:auto_minor_version_upgrade), its(:read_replica_source_db_instance_identifier), its(:read_replica_db_instance_identifiers), its(:read_replica_db_cluster_identifiers), its(:replica_mode), its(:license_model), its(:iops), its(:character_set_name), its(:nchar_character_set_name), its(:secondary_availability_zone), its(:publicly_accessible), its(:status_infos), its(:storage_type), its(:tde_credential_arn), its(:db_instance_port), its(:db_cluster_identifier), its(:storage_encrypted), its(:kms_key_id), its(:dbi_resource_id), its(:ca_certificate_identifier), its(:domain_memberships), its(:copy_tags_to_snapshot), its(:monitoring_interval), its(:enhanced_monitoring_resource_arn), its(:monitoring_role_arn), its(:promotion_tier), its(:db_instance_arn), its(:timezone), its(:iam_database_authentication_enabled), its(:performance_insights_enabled), its(:performance_insights_kms_key_id), its(:performance_insights_retention_period), its(:enabled_cloudwatch_logs_exports), its(:processor_features), its(:deletion_protection), its(:associated_roles), its(:listener_endpoint), its(:max_allocated_storage), its(:tag_list), its(:db_instance_automated_backups_replications), its(:customer_owned_ip_enabled), its(:aws_backup_recovery_point_arn), its(:activity_stream_status), its(:activity_stream_kms_key_id), its(:activity_stream_kinesis_stream_name), its(:activity_stream_mode), its(:activity_stream_engine_native_audit_fields_included), its(:automation_mode), its(:resume_full_automation_mode_time), its(:custom_iam_instance_profile), its(:backup_target), its(:network_type), its(:activity_stream_policy_status)
2860
2863
  ### :unlock: Advanced use
2861
2864
 
2862
2865
  `rds` can use `Aws::RDS::DBInstance` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/DBInstance.html).
@@ -2875,6 +2878,61 @@ describe rds('my-rds') do
2875
2878
  end
2876
2879
  ```
2877
2880
 
2881
+ ## <a name="rds_db_cluster">rds_db_cluster</a>
2882
+
2883
+ RdsDbCluster resource type.
2884
+
2885
+ ```ruby
2886
+ describe rds_db_cluster('my-rds-db-cluster') do
2887
+ its(:db_cluster_parameter_group) { should eq 'default.aurora-mysql5.7' }
2888
+ its(:engine) { should eq 'aurora-mysql' }
2889
+ its(:engine_version) { should eq '5.7.mysql_aurora.2.10.2' }
2890
+ its(:database_name) { should eq 'example_db' }
2891
+ its(:storage_encrypted) { should eq false }
2892
+ its(:deletion_protection) { should eq false }
2893
+ end
2894
+ ```
2895
+
2896
+
2897
+ ### exist
2898
+
2899
+ ```ruby
2900
+ describe rds_db_cluster('my-rds-db-cluster') do
2901
+ it { should exist }
2902
+ end
2903
+ ```
2904
+
2905
+
2906
+ ### be_available, be_creating, be_deleting
2907
+
2908
+ ```ruby
2909
+ describe rds_db_cluster('my-rds-db-cluster') do
2910
+ it { should be_available }
2911
+ end
2912
+ ```
2913
+
2914
+
2915
+ ### have_cluster_member
2916
+
2917
+ ```ruby
2918
+ describe rds_db_cluster('my-rds-db-cluster') do
2919
+ it { should have_cluster_member('my-rds-db-cluster-instance-1') }
2920
+ it { should have_cluster_member('my-rds-db-cluster-instance-1').is_writer(true) }
2921
+ it { should have_cluster_member('my-rds-db-cluster-instance-2').is_writer(false) }
2922
+ end
2923
+ ```
2924
+
2925
+
2926
+ ### have_security_group
2927
+
2928
+ ```ruby
2929
+ describe rds_db_cluster('my-rds-db-cluster') do
2930
+ it { should have_security_group('sg-5a6b7cd8') }
2931
+ it { should have_security_group('my-db-sg') }
2932
+ end
2933
+ ```
2934
+
2935
+ ### its(:allocated_storage), its(:availability_zones), its(:backup_retention_period), its(:character_set_name), its(:database_name), its(:db_cluster_identifier), its(:db_cluster_parameter_group), its(:db_subnet_group), its(:status), its(:automatic_restart_time), its(:percent_progress), its(:earliest_restorable_time), its(:endpoint), its(:reader_endpoint), its(:custom_endpoints), its(:multi_az), its(:engine), its(:engine_version), its(:latest_restorable_time), its(:port), its(:master_username), its(:db_cluster_option_group_memberships), its(:preferred_backup_window), its(:preferred_maintenance_window), its(:replication_source_identifier), its(:read_replica_identifiers), its(:hosted_zone_id), its(:storage_encrypted), its(:kms_key_id), its(:db_cluster_resource_id), its(:db_cluster_arn), its(:associated_roles), its(:iam_database_authentication_enabled), its(:clone_group_id), its(:cluster_create_time), its(:earliest_backtrack_time), its(:backtrack_window), its(:backtrack_consumed_change_records), its(:enabled_cloudwatch_logs_exports), its(:capacity), its(:engine_mode), its(:scaling_configuration_info), its(:deletion_protection), its(:http_endpoint_enabled), its(:activity_stream_mode), its(:activity_stream_status), its(:activity_stream_kms_key_id), its(:activity_stream_kinesis_stream_name), its(:copy_tags_to_snapshot), its(:cross_account_clone), its(:domain_memberships), its(:tag_list), its(:global_write_forwarding_status), its(:global_write_forwarding_requested), its(:pending_modified_values), its(:db_cluster_instance_class), its(:storage_type), its(:iops), its(:publicly_accessible), its(:auto_minor_version_upgrade), its(:monitoring_interval), its(:monitoring_role_arn), its(:performance_insights_enabled), its(:performance_insights_kms_key_id), its(:performance_insights_retention_period), its(:serverless_v2_scaling_configuration)
2878
2936
  ## <a name="rds_db_cluster_parameter_group">rds_db_cluster_parameter_group</a>
2879
2937
 
2880
2938
  RdsDbClusterParameterGroup resource type.
@@ -2916,6 +2974,83 @@ end
2916
2974
  ```
2917
2975
 
2918
2976
 
2977
+ ## <a name="rds_db_subnet_group">rds_db_subnet_group</a>
2978
+
2979
+ RdsDbSubnetGroup resource type.
2980
+
2981
+ ### exist
2982
+
2983
+ ```ruby
2984
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
2985
+ it { should exist }
2986
+ end
2987
+ ```
2988
+
2989
+
2990
+ ### belong_to_subnet
2991
+
2992
+ ```ruby
2993
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
2994
+ it { should belong_to_subnet('subnet-1234a567') }
2995
+ it { should belong_to_subnet('db-subnet-a') }
2996
+ end
2997
+ ```
2998
+
2999
+
3000
+ ### belong_to_vpc
3001
+
3002
+ ```ruby
3003
+ describe rds_db_subnet_group('my-rds-db-subnet-group') do
3004
+ it { should belong_to_vpc('vpc-ab123cde') }
3005
+ it { should belong_to_vpc('my-vpc') }
3006
+ end
3007
+ ```
3008
+
3009
+ ### its(:vpc_id), its(:db_subnet_group_name), its(:db_subnet_group_description), its(:vpc_id), its(:subnet_group_status), its(:db_subnet_group_arn), its(:supported_network_types)
3010
+ ## <a name="rds_global_cluster">rds_global_cluster</a>
3011
+
3012
+ RdsGlobalCluster resource type.
3013
+
3014
+ ```ruby
3015
+ describe rds_global_cluster('my-rds-global-cluster') do
3016
+ its(:engine) { should eq 'aurora-mysql' }
3017
+ its(:engine_version) { should eq '5.7.mysql_aurora.2.10.2' }
3018
+ its(:database_name) { should eq 'example_db' }
3019
+ its(:storage_encrypted) { should eq false }
3020
+ its(:deletion_protection) { should eq false }
3021
+ end
3022
+ ```
3023
+
3024
+
3025
+ ### exist
3026
+
3027
+ ```ruby
3028
+ describe rds_global_cluster('my-rds-global-cluster') do
3029
+ it { should exist }
3030
+ end
3031
+ ```
3032
+
3033
+
3034
+ ### be_available, be_creating, be_deleting
3035
+
3036
+ ```ruby
3037
+ describe rds_global_cluster('my-rds-global-cluster') do
3038
+ it { should be_available }
3039
+ end
3040
+ ```
3041
+
3042
+
3043
+ ### have_cluster_member
3044
+
3045
+ ```ruby
3046
+ describe rds_global_cluster('my-rds-global-cluster') do
3047
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-1:123456789012:cluster:my-primary-cluster') }
3048
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-1:123456789012:cluster:my-primary-cluster').is_writer(true) }
3049
+ it { should have_cluster_member('arn:aws:rds:ap-northeast-3:123456789012:cluster:my-secondary-cluster').is_writer(false) }
3050
+ end
3051
+ ```
3052
+
3053
+ ### its(:global_cluster_identifier), its(:global_cluster_resource_id), its(:global_cluster_arn), its(:status), its(:engine), its(:engine_version), its(:database_name), its(:storage_encrypted), its(:deletion_protection), its(:failover_state)
2919
3054
  ## <a name="rds_proxy">rds_proxy</a>
2920
3055
 
2921
3056
  RdsProxy resource type.
@@ -50,6 +50,18 @@ module Awspec
50
50
  end
51
51
  end
52
52
 
53
+ types = %w[
54
+ rds_db_cluster rds_global_cluster
55
+ ]
56
+
57
+ types.each do |type|
58
+ desc "#{type} [cluster_identifier]", "Generate #{type} spec from cluster identifier."
59
+ define_method type do |_cluster_identifier|
60
+ Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
61
+ eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate(_cluster_identifier)"
62
+ end
63
+ end
64
+
53
65
  types_for_generate_all = %w[
54
66
  cloudwatch_alarm cloudwatch_event directconnect ebs efs
55
67
  elasticsearch iam_group iam_policy iam_role iam_user kms lambda
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Generator
4
+ module Doc
5
+ module Type
6
+ class RdsDbCluster < Base
7
+ def initialize
8
+ super
9
+ @type_name = 'RdsDbCluster'
10
+ @type = Awspec::Type::RdsDbCluster.new('my-rds-db-cluster')
11
+ @ret = @type.resource_via_client
12
+ @matchers = [
13
+ Awspec::Type::RdsDbCluster::STATES.map { |state| "be_#{state.tr('-', '_')}" }.join(', ')
14
+ ]
15
+ @ignore_matchers = Awspec::Type::RdsDbCluster::STATES.map { |state| "be_#{state.tr('-', '_')}" }
16
+ @describes = []
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Generator
4
+ module Doc
5
+ module Type
6
+ class RdsDbSubnetGroup < Base
7
+ def initialize
8
+ super
9
+ @type_name = 'RdsDbSubnetGroup'
10
+ @type = Awspec::Type::RdsDbSubnetGroup.new('my-rds-db-subnet-group')
11
+ @ret = @type.resource_via_client
12
+ @matchers = %w[belong_to_vpc belong_to_subnet]
13
+ @ignore_matchers = []
14
+ @describes = %w[vpc_id]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Generator
4
+ module Doc
5
+ module Type
6
+ class RdsGlobalCluster < Base
7
+ def initialize
8
+ super
9
+ @type_name = 'RdsGlobalCluster'
10
+ @type = Awspec::Type::RdsGlobalCluster.new('my-rds-global-cluster')
11
+ @ret = @type.resource_via_client
12
+ @matchers = [
13
+ Awspec::Type::RdsGlobalCluster::STATES.map { |state| "be_#{state.tr('-', '_')}" }.join(', ')
14
+ ]
15
+ @ignore_matchers = Awspec::Type::RdsGlobalCluster::STATES.map { |state| "be_#{state.tr('-', '_')}" }
16
+ @describes = []
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Generator
4
+ module Spec
5
+ class RdsDbCluster
6
+ include Awspec::Helper::Finder
7
+ def generate(db_cluster_identifier)
8
+ cluster = find_db_cluster(db_cluster_identifier)
9
+ raise 'Not Found RDS DB Cluster' unless cluster
10
+
11
+ content(cluster)
12
+ end
13
+
14
+ # rubocop:disable all
15
+ def rds_db_cluster_spec_template
16
+ template = <<-'EOF'
17
+ describe rds_db_cluster('<%= cluster.db_cluster_identifier %>') do
18
+ it { should exist }
19
+ it { should be_<%= cluster.status %> }
20
+ <% cluster.vpc_security_groups.each do |sg| %>
21
+ it { should have_security_group('<%= sg.vpc_security_group_id %>') }
22
+ <% end %>
23
+ <% cluster.db_cluster_members.each do |member| %>
24
+ it { should have_cluster_member('<%= member.db_instance_identifier %>').is_writer(<%= member.is_cluster_writer %>) }
25
+ <% end %>
26
+ its(:db_cluster_parameter_group) { should eq '<%= cluster.db_cluster_parameter_group %>' }
27
+ its(:engine) { should eq '<%= cluster.engine %>' }
28
+ its(:engine_version) { should eq '<%= cluster.engine_version %>' }
29
+ its(:database_name) { should eq '<%= cluster.database_name %>' }
30
+ its(:storage_encrypted) { should eq <%= cluster.storage_encrypted %> }
31
+ its(:deletion_protection) { should eq <%= cluster.deletion_protection %> }
32
+ its(:port) { should eq <%= cluster.port %> }
33
+ its(:master_username) { should eq '<%= cluster.master_username %>' }
34
+ end
35
+ EOF
36
+ template
37
+ end
38
+
39
+ private
40
+
41
+ def content(cluster)
42
+ ERB.new(rds_db_cluster_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Generator
4
+ module Spec
5
+ class RdsGlobalCluster
6
+ include Awspec::Helper::Finder
7
+ def generate(global_cluster_identifier)
8
+ cluster = find_global_cluster(global_cluster_identifier)
9
+ raise 'Not Found RDS Global Cluster' unless cluster
10
+
11
+ content(cluster)
12
+ end
13
+
14
+ # rubocop:disable all
15
+ def rds_global_cluster_spec_template
16
+ template = <<-'EOF'
17
+ describe rds_global_cluster('<%= cluster.global_cluster_identifier %>') do
18
+ it { should exist }
19
+ it { should be_<%= cluster.status %> }
20
+ <% cluster.global_cluster_members.each do |member| %>
21
+ it { should have_cluster_member('<%= member.db_cluster_arn %>').is_writer(<%= member.is_writer %>) }
22
+ <% end %>
23
+ its(:engine) { should eq '<%= cluster.engine %>' }
24
+ its(:engine_version) { should eq '<%= cluster.engine_version %>' }
25
+ its(:database_name) { should eq '<%= cluster.database_name %>' }
26
+ its(:storage_encrypted) { should eq <%= cluster.storage_encrypted %> }
27
+ its(:deletion_protection) { should eq <%= cluster.deletion_protection %> }
28
+ end
29
+ EOF
30
+ template
31
+ end
32
+
33
+ private
34
+
35
+ def content(cluster)
36
+ ERB.new(rds_global_cluster_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -35,7 +35,7 @@ module Awspec::Type
35
35
  end
36
36
 
37
37
  def id
38
- @id ||= # FIXME
38
+ @id ||= # FIXME
39
39
  end
40
40
  end
41
41
  end
@@ -41,6 +41,8 @@ require 'awspec/generator/spec/nlb_listener'
41
41
  require 'awspec/generator/spec/redshift'
42
42
  require 'awspec/generator/spec/redshift_cluster_parameter_group'
43
43
  require 'awspec/generator/spec/rds_proxy'
44
+ require 'awspec/generator/spec/rds_db_cluster'
45
+ require 'awspec/generator/spec/rds_global_cluster'
44
46
 
45
47
  # Doc
46
48
  require 'awspec/generator/doc/type'
@@ -71,6 +71,27 @@ module Awspec::Helper
71
71
  db_proxy.vpc_id == vpc_id
72
72
  end
73
73
  end
74
+
75
+ def find_db_cluster(db_cluster_identifier)
76
+ res = rds_client.describe_db_clusters({
77
+ db_cluster_identifier: db_cluster_identifier
78
+ })
79
+ res.db_clusters.single_resource(db_cluster_identifier)
80
+ end
81
+
82
+ def find_global_cluster(global_cluster_identifier)
83
+ res = rds_client.describe_global_clusters({
84
+ global_cluster_identifier: global_cluster_identifier
85
+ })
86
+ res.global_clusters.single_resource(global_cluster_identifier)
87
+ end
88
+
89
+ def find_db_subnet_group(db_subnet_group_name)
90
+ res = rds_client.describe_db_subnet_groups({
91
+ db_subnet_group_name: db_subnet_group_name
92
+ })
93
+ res.db_subnet_groups.single_resource(db_subnet_group_name)
94
+ end
74
95
  end
75
96
  end
76
97
  end
@@ -17,8 +17,9 @@ module Awspec
17
17
  efs eks eks_nodegroup elasticache elasticache_cache_parameter_group elasticsearch elb emr firehose iam_group
18
18
  iam_policy iam_role iam_user kinesis kms lambda launch_configuration launch_template mq nat_gateway
19
19
  network_acl network_interface nlb nlb_listener nlb_target_group
20
- rds rds_proxy rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
21
- route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
20
+ rds rds_proxy rds_db_cluster_parameter_group rds_db_parameter_group rds_db_subnet_group
21
+ rds_db_cluster rds_global_cluster
22
+ route53_hosted_zone route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
22
23
  elastictranscoder_pipeline waf_web_acl wafregional_web_acl customer_gateway vpn_gateway vpn_connection
23
24
  internet_gateway acm cloudwatch_logs dynamodb_table eip sqs ssm_parameter cloudformation_stack
24
25
  codebuild sns_topic redshift redshift_cluster_parameter_group codedeploy codedeploy_deployment_group
@@ -33,6 +33,27 @@ RSpec::Matchers.define :belong_to_subnet do |subnet_id|
33
33
  return ret[:subnet_availability_zone][:name] == type.availability_zone if ret
34
34
  end
35
35
 
36
+ # RDS DB Subnet Group
37
+ if type.instance_of?(Awspec::Type::RdsDbSubnetGroup)
38
+ subnets = type.resource_via_client[:subnets]
39
+ ret = subnets.find do |s|
40
+ s[:subnet_identifier] == subnet_id
41
+ end
42
+
43
+ return true if ret
44
+
45
+ res = type.ec2_client.describe_subnets({
46
+ filters: [{ name: 'tag:Name', values: [subnet_id] }]
47
+ })
48
+ return false unless res
49
+
50
+ ret = subnets.find do |s|
51
+ s[:subnet_identifier] == res[:subnets][0][:subnet_id]
52
+ end
53
+
54
+ return ret ? true : false
55
+ end
56
+
36
57
  # RDS Proxy
37
58
  if type.instance_of?(Awspec::Type::RdsProxy)
38
59
  subnet_ids = type.resource_via_client[:vpc_subnet_ids]
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_cluster_member do |name|
4
+ match do |cluster_identifier|
5
+ cluster_identifier.has_cluster_member?(name, @is_writer)
6
+ end
7
+
8
+ chain :is_writer do |is_writer|
9
+ @is_writer = is_writer
10
+ end
11
+ end
@@ -13,6 +13,7 @@ require 'awspec/matcher/belong_to_subnets'
13
13
  require 'awspec/matcher/belong_to_db_subnet_group'
14
14
  require 'awspec/matcher/have_db_parameter_group'
15
15
  require 'awspec/matcher/have_option_group'
16
+ require 'awspec/matcher/have_cluster_member'
16
17
 
17
18
  # SecurityGroup
18
19
  require 'awspec/matcher/be_opened'
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ Aws.config[:rds] = {
4
+ stub_responses: {
5
+ describe_db_clusters: {
6
+ db_clusters: [
7
+ {
8
+ allocated_storage: 1,
9
+ availability_zones: %w[ap-northeast-1a ap-northeast-1c ap-northeast-1d],
10
+ backup_retention_period: 1,
11
+ character_set_name: nil,
12
+ database_name: 'example_db',
13
+ db_cluster_identifier: 'my-rds-db-cluster',
14
+ db_cluster_parameter_group: 'default.aurora-mysql5.7',
15
+ db_subnet_group: 'default',
16
+ status: 'available',
17
+ automatic_restart_time: nil,
18
+ percent_progress: nil,
19
+ earliest_restorable_time: Time.local(2022),
20
+ endpoint: 'my-rds-db-cluster.cluster-abcdefghij12.ap-northeast-1.rds.amazonaws.com',
21
+ reader_endpoint: 'my-rds-db-cluster.cluster-ro-abcdefghij12.ap-northeast-1.rds.amazonaws.com',
22
+ custom_endpoints: [],
23
+ multi_az: false,
24
+ engine: 'aurora-mysql',
25
+ engine_version: '5.7.mysql_aurora.2.10.2',
26
+ latest_restorable_time: Time.local(2022),
27
+ port: 3306,
28
+ master_username: 'username',
29
+ db_cluster_option_group_memberships: [],
30
+ preferred_backup_window: '14:09-14:39',
31
+ preferred_maintenance_window: 'sun:17:01-sun:17:31',
32
+ replication_source_identifier: nil,
33
+ read_replica_identifiers: [
34
+ 'arn:aws:rds:ap-northeast-3:123456789012:cluster:my-rds-secondary-cluster'
35
+ ],
36
+ db_cluster_members: [
37
+ {
38
+ db_instance_identifier: 'my-rds-db-cluster-instance-1',
39
+ is_cluster_writer: true,
40
+ db_cluster_parameter_group_status: 'in-sync',
41
+ promotion_tier: 0
42
+ },
43
+ {
44
+ db_instance_identifier: 'my-rds-db-cluster-instance-2',
45
+ is_cluster_writer: false,
46
+ db_cluster_parameter_group_status: 'in-sync',
47
+ promotion_tier: 0
48
+ }
49
+ ],
50
+ vpc_security_groups: [
51
+ {
52
+ vpc_security_group_id: 'sg-5a6b7cd8',
53
+ status: 'active'
54
+ }
55
+ ],
56
+ hosted_zone_id: 'Z24O6O9L7SGTNB',
57
+ storage_encrypted: false,
58
+ kms_key_id: nil,
59
+ db_cluster_resource_id: 'cluster-ABCDEFGHIJKLMNOPQRSTUVWXYZ',
60
+ db_cluster_arn: 'arn:aws:rds:ap-northeast-1:123456789012:cluster:my-rds-db-cluster',
61
+ associated_roles: [],
62
+ iam_database_authentication_enabled: false,
63
+ clone_group_id: nil,
64
+ cluster_create_time: Time.local(2022),
65
+ earliest_backtrack_time: nil,
66
+ backtrack_window: nil,
67
+ backtrack_consumed_change_records: nil,
68
+ enabled_cloudwatch_logs_exports: [],
69
+ capacity: nil,
70
+ engine_mode: 'provisioned',
71
+ scaling_configuration_info: nil,
72
+ deletion_protection: false,
73
+ http_endpoint_enabled: false,
74
+ activity_stream_mode: nil,
75
+ activity_stream_status: 'stopped',
76
+ activity_stream_kms_key_id: nil,
77
+ activity_stream_kinesis_stream_name: nil,
78
+ copy_tags_to_snapshot: false,
79
+ cross_account_clone: false,
80
+ domain_memberships: [],
81
+ tag_list: [],
82
+ global_write_forwarding_status: nil,
83
+ global_write_forwarding_requested: false,
84
+ pending_modified_values: nil,
85
+ db_cluster_instance_class: nil,
86
+ storage_type: nil,
87
+ iops: nil,
88
+ publicly_accessible: nil,
89
+ monitoring_interval: nil,
90
+ monitoring_role_arn: nil,
91
+ performance_insights_enabled: nil,
92
+ performance_insights_kms_key_id: nil,
93
+ performance_insights_retention_period: nil,
94
+ serverless_v2_scaling_configuration: nil
95
+ }
96
+ ],
97
+ marker: nil
98
+ }
99
+ }
100
+ }
101
+
102
+ Aws.config[:ec2] = {
103
+ stub_responses: {
104
+ describe_security_groups: {
105
+ security_groups: [
106
+ {
107
+ group_id: 'sg-5a6b7cd8',
108
+ group_name: 'group-name-sg',
109
+ tags: [
110
+ {
111
+ key: 'Name',
112
+ value: 'my-db-sg'
113
+ }
114
+ ]
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ Aws.config[:rds] = {
4
+ stub_responses: {
5
+ describe_db_subnet_groups: {
6
+ db_subnet_groups: [
7
+ {
8
+ db_subnet_group_name: 'my-rds-db-subnet-group',
9
+ db_subnet_group_description: 'Created from the RDS Management Console',
10
+ vpc_id: 'vpc-ab123cde',
11
+ subnet_group_status: 'Complete',
12
+ subnets: [
13
+ {
14
+ subnet_identifier: 'subnet-1234a567',
15
+ subnet_availability_zone: {
16
+ name: 'ap-northeast-1a'
17
+ },
18
+ subnet_outpost: {
19
+ arn: nil
20
+ },
21
+ subnet_status: 'Active'
22
+ },
23
+ {
24
+ subnet_identifier: 'subnet-1234b567',
25
+ subnet_availability_zone: {
26
+ name: 'ap-northeast-1c'
27
+ },
28
+ subnet_outpost: {
29
+ arn: nil
30
+ },
31
+ subnet_status: 'Active'
32
+ },
33
+ {
34
+ subnet_identifier: 'subnet-1234c567',
35
+ subnet_availability_zone: {
36
+ name: 'ap-northeast-1d'
37
+ },
38
+ subnet_outpost: {
39
+ arn: nil
40
+ },
41
+ subnet_status: 'Active'
42
+ }
43
+ ],
44
+ db_subnet_group_arn: 'arn:aws:rds:ap-northeast-1:123456789012:subgrp:my-rds-db-subnet-group'
45
+ }
46
+ ],
47
+ marker: nil
48
+ }
49
+ }
50
+ }
51
+
52
+ Aws.config[:ec2] = {
53
+ stub_responses: {
54
+ describe_vpcs: {
55
+ vpcs: [
56
+ {
57
+ vpc_id: 'vpc-ab123cde',
58
+ tags: [
59
+ {
60
+ key: 'Name',
61
+ value: 'my-vpc'
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ },
67
+ describe_subnets: {
68
+ subnets: [
69
+ {
70
+ subnet_id: 'subnet-1234a567',
71
+ tags: [
72
+ {
73
+ key: 'Name',
74
+ value: 'db-subnet-a'
75
+ }
76
+ ]
77
+ }
78
+ ]
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ Aws.config[:rds] = {
4
+ stub_responses: {
5
+ describe_global_clusters: {
6
+ global_clusters: [
7
+ {
8
+ global_cluster_identifier: 'my-rds-global-cluster',
9
+ global_cluster_resource_id: 'cluster-1234567890abcdef',
10
+ global_cluster_arn: 'arn:aws:rds::123456789012:global-cluster:my-rds-global-cluster',
11
+ status: 'available',
12
+ engine: 'aurora-mysql',
13
+ engine_version: '5.7.mysql_aurora.2.10.2',
14
+ database_name: 'example_db',
15
+ storage_encrypted: false,
16
+ deletion_protection: false,
17
+ global_cluster_members: [
18
+ {
19
+ db_cluster_arn: 'arn:aws:rds:ap-northeast-1:123456789012:cluster:my-primary-cluster',
20
+ readers: [
21
+ 'arn:aws:rds:ap-northeast-3:123456789012:cluster:my-secondary-cluster'
22
+ ],
23
+ is_writer: true,
24
+ global_write_forwarding_status: nil
25
+ },
26
+ {
27
+ db_cluster_arn: 'arn:aws:rds:ap-northeast-3:123456789012:cluster:my-secondary-cluster',
28
+ readers: [],
29
+ is_writer: false,
30
+ global_write_forwarding_status: 'disabled'
31
+ }
32
+ ],
33
+ failover_state: nil
34
+ }
35
+ ],
36
+ marker: nil
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class RdsDbCluster < ResourceBase
5
+ aws_resource Aws::RDS::Types::DBCluster
6
+
7
+ def resource_via_client
8
+ @resource_via_client ||= find_db_cluster(@display_name)
9
+ end
10
+
11
+ def id
12
+ @id ||= resource_via_client.db_cluster_identifier if resource_via_client
13
+ end
14
+
15
+ STATES = %w[
16
+ available creating deleting
17
+ ]
18
+
19
+ STATES.each do |state|
20
+ define_method "#{state.tr('-', '_')}?" do
21
+ resource_via_client.status == state
22
+ end
23
+ end
24
+
25
+ def has_security_group?(sg_id)
26
+ return true if has_vpc_security_group_id?(sg_id)
27
+ return true if has_vpc_security_group_name?(sg_id)
28
+ return true if has_vpc_security_group_tag_name?(sg_id)
29
+ end
30
+
31
+ def has_cluster_member?(db_instance_identifier, is_writer = nil)
32
+ members = resource_via_client.db_cluster_members
33
+ members.find do |member|
34
+ if is_writer.nil?
35
+ member.db_instance_identifier == db_instance_identifier
36
+ else
37
+ member.db_instance_identifier == db_instance_identifier && member.is_cluster_writer == is_writer
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def has_vpc_security_group_id?(sg_id)
45
+ sgs = resource_via_client.vpc_security_groups
46
+ sgs.find do |sg|
47
+ sg.vpc_security_group_id == sg_id
48
+ end
49
+ end
50
+
51
+ def has_vpc_security_group_name?(sg_id)
52
+ sgs = resource_via_client.vpc_security_groups
53
+ res = ec2_client.describe_security_groups({
54
+ filters: [{ name: 'group-name', values: [sg_id] }]
55
+ })
56
+ return false unless res.security_groups.count == 1
57
+
58
+ sgs.find do |sg|
59
+ sg.vpc_security_group_id == res.security_groups.first.group_id
60
+ end
61
+ end
62
+
63
+ def has_vpc_security_group_tag_name?(sg_id)
64
+ sgs = resource_via_client.vpc_security_groups
65
+ res = ec2_client.describe_security_groups({
66
+ filters: [{ name: 'tag:Name', values: [sg_id] }]
67
+ })
68
+ return false unless res.security_groups.count == 1
69
+
70
+ sgs.find do |sg|
71
+ sg.vpc_security_group_id == res.security_groups.first.group_id
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class RdsDbSubnetGroup < ResourceBase
5
+ aws_resource Aws::RDS::Types::DBSubnetGroup
6
+
7
+ def resource_via_client
8
+ @resource_via_client ||= find_db_subnet_group(@display_name)
9
+ end
10
+
11
+ def id
12
+ @id ||= resource_via_client.db_subnet_group_name if resource_via_client
13
+ end
14
+
15
+ def vpc_id
16
+ resource_via_client.vpc_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Awspec::Type
4
+ class RdsGlobalCluster < ResourceBase
5
+ aws_resource Aws::RDS::Types::GlobalCluster
6
+
7
+ def resource_via_client
8
+ @resource_via_client ||= find_global_cluster(@display_name)
9
+ end
10
+
11
+ def id
12
+ @id ||= resource_via_client.global_cluster_identifier if resource_via_client
13
+ end
14
+
15
+ STATES = %w[
16
+ available creating deleting
17
+ ]
18
+
19
+ STATES.each do |state|
20
+ define_method "#{state.tr('-', '_')}?" do
21
+ resource_via_client.status == state
22
+ end
23
+ end
24
+
25
+ def has_cluster_member?(db_cluster_arn, is_writer = nil)
26
+ members = resource_via_client.global_cluster_members
27
+ members.find do |member|
28
+ if is_writer.nil?
29
+ member.db_cluster_arn == db_cluster_arn
30
+ else
31
+ member.db_cluster_arn == db_cluster_arn && member.is_writer == is_writer
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Awspec
4
- VERSION = '1.27.1'
4
+ VERSION = '1.28.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.1
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -309,8 +309,11 @@ files:
309
309
  - doc/_resource_types/nlb_target_group.md
310
310
  - doc/_resource_types/rds.md
311
311
  - doc/_resource_types/rds_account_attributes.md
312
+ - doc/_resource_types/rds_db_cluster.md
312
313
  - doc/_resource_types/rds_db_cluster_parameter_group.md
313
314
  - doc/_resource_types/rds_db_parameter_group.md
315
+ - doc/_resource_types/rds_db_subnet_group.md
316
+ - doc/_resource_types/rds_global_cluster.md
314
317
  - doc/_resource_types/rds_proxy.md
315
318
  - doc/_resource_types/redshift.md
316
319
  - doc/_resource_types/redshift_cluster_parameter_group.md
@@ -416,8 +419,11 @@ files:
416
419
  - lib/awspec/generator/doc/type/nlb_target_group.rb
417
420
  - lib/awspec/generator/doc/type/rds.rb
418
421
  - lib/awspec/generator/doc/type/rds_account_attributes.rb
422
+ - lib/awspec/generator/doc/type/rds_db_cluster.rb
419
423
  - lib/awspec/generator/doc/type/rds_db_cluster_parameter_group.rb
420
424
  - lib/awspec/generator/doc/type/rds_db_parameter_group.rb
425
+ - lib/awspec/generator/doc/type/rds_db_subnet_group.rb
426
+ - lib/awspec/generator/doc/type/rds_global_cluster.rb
421
427
  - lib/awspec/generator/doc/type/rds_proxy.rb
422
428
  - lib/awspec/generator/doc/type/redshift.rb
423
429
  - lib/awspec/generator/doc/type/redshift_cluster_parameter_group.rb
@@ -469,8 +475,10 @@ files:
469
475
  - lib/awspec/generator/spec/nlb.rb
470
476
  - lib/awspec/generator/spec/nlb_listener.rb
471
477
  - lib/awspec/generator/spec/rds.rb
478
+ - lib/awspec/generator/spec/rds_db_cluster.rb
472
479
  - lib/awspec/generator/spec/rds_db_cluster_parameter_group.rb
473
480
  - lib/awspec/generator/spec/rds_db_parameter_group.rb
481
+ - lib/awspec/generator/spec/rds_global_cluster.rb
474
482
  - lib/awspec/generator/spec/rds_proxy.rb
475
483
  - lib/awspec/generator/spec/redshift.rb
476
484
  - lib/awspec/generator/spec/redshift_cluster_parameter_group.rb
@@ -563,6 +571,7 @@ files:
563
571
  - lib/awspec/matcher/belong_to_subnets.rb
564
572
  - lib/awspec/matcher/belong_to_vpc.rb
565
573
  - lib/awspec/matcher/have_attribute_definition.rb
574
+ - lib/awspec/matcher/have_cluster_member.rb
566
575
  - lib/awspec/matcher/have_cluster_parameter_group.rb
567
576
  - lib/awspec/matcher/have_custom_response_error_code.rb
568
577
  - lib/awspec/matcher/have_db_parameter_group.rb
@@ -655,8 +664,11 @@ files:
655
664
  - lib/awspec/stub/nlb_listener.rb
656
665
  - lib/awspec/stub/nlb_target_group.rb
657
666
  - lib/awspec/stub/rds.rb
667
+ - lib/awspec/stub/rds_db_cluster.rb
658
668
  - lib/awspec/stub/rds_db_cluster_parameter_group.rb
659
669
  - lib/awspec/stub/rds_db_parameter_group.rb
670
+ - lib/awspec/stub/rds_db_subnet_group.rb
671
+ - lib/awspec/stub/rds_global_cluster.rb
660
672
  - lib/awspec/stub/rds_proxy.rb
661
673
  - lib/awspec/stub/redshift.rb
662
674
  - lib/awspec/stub/redshift_cluster_parameter_group.rb
@@ -748,8 +760,11 @@ files:
748
760
  - lib/awspec/type/nlb_target_group.rb
749
761
  - lib/awspec/type/rds.rb
750
762
  - lib/awspec/type/rds_account_attributes.rb
763
+ - lib/awspec/type/rds_db_cluster.rb
751
764
  - lib/awspec/type/rds_db_cluster_parameter_group.rb
752
765
  - lib/awspec/type/rds_db_parameter_group.rb
766
+ - lib/awspec/type/rds_db_subnet_group.rb
767
+ - lib/awspec/type/rds_global_cluster.rb
753
768
  - lib/awspec/type/rds_proxy.rb
754
769
  - lib/awspec/type/redshift.rb
755
770
  - lib/awspec/type/redshift_cluster_parameter_group.rb