awspec 1.24.2 → 1.25.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 846285926375fd9f812d6110b9b6f82918a1cd217dde0b51e3e87694fa39861c
4
- data.tar.gz: b9b0d5c955add005d788b35ace982d75a74843cb8bb0c4cc86cbf931bb6cb68e
3
+ metadata.gz: 859f812366b731851141a0f2fb663d7861e537fbff4c349a2cf63468944eb142
4
+ data.tar.gz: fc866492dce252ec352f1228adb45ceb27a9538f14052c903b054669774ad609
5
5
  SHA512:
6
- metadata.gz: 6d2af549c10d9e3634e6e7ff809b6bb3a5518dc3a9ae52e70963718a19aa2731cd274b9bbbba614989b49253eb85e4f806487692c7a7f72c7135dda58162fb5b
7
- data.tar.gz: 0aa25037fc049461e9558c57af0b7f6ab02b70cb43b4637496edfb7715704d8abd821b2f52bebc7a4a2ea3bf6ba95d5d9034102084667d249dce7f8584ee8a97
6
+ metadata.gz: 4c7680dfed99c2e4e85521f894a01cbc84c8fdbbbe27bb1b470b16e14e072bbe19974184c68d9c7f269178f325c8945c3f485947563d354346aad6d42b5c54c9
7
+ data.tar.gz: 6c72be4d376fac4247265ae8372f7466316f529277eeb39e3d25d30a02aaef356b1928fe492d2b1e0f7ee2866b281a1fb8ba81d640031d702fda10368b239c5f
@@ -0,0 +1,69 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ name: Lint
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.7
21
+ bundler-cache: true
22
+
23
+ - name: Run rubocop
24
+ uses: reviewdog/action-rubocop@v1
25
+ with:
26
+ rubocop_version: 0.57.2
27
+ rubocop_extensions: rubocop:0.57.2
28
+ github_token: ${{ secrets.GITHUB_TOKEN }}
29
+ reporter: github-pr-review
30
+ fail_on_error: true
31
+
32
+ test:
33
+ name: Test
34
+ needs: [ lint ]
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ ruby-version:
39
+ - '2.1'
40
+ - '2.2'
41
+ - '2.3'
42
+ - '2.4'
43
+ - '2.5'
44
+ - '2.6'
45
+ - '2.7'
46
+ # - '3.0'
47
+ runs-on: ubuntu-latest
48
+ env:
49
+ DISABLE_AWS_CLIENT_CHECK: true
50
+
51
+ steps:
52
+ - name: Checkout
53
+ uses: actions/checkout@v2
54
+
55
+ - name: Set up Ruby
56
+ uses: ruby/setup-ruby@v1
57
+ with:
58
+ ruby-version: ${{ matrix.ruby-version }}
59
+ bundler-cache: true
60
+
61
+ - name: Install xml lib
62
+ run: gem install ox
63
+ if: matrix.ruby-version == '3.0'
64
+
65
+ - name: Generate document
66
+ run: bundle exec bin/toolbox docgen > doc/resource_types.md
67
+
68
+ - name: Run tests
69
+ run: bundle exec rake spec
@@ -0,0 +1,29 @@
1
+ name: Doc
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 0 * * 0'
6
+
7
+ jobs:
8
+ doc:
9
+ name: Document
10
+ runs-on: ubuntu-latest
11
+ env:
12
+ DISABLE_AWS_CLIENT_CHECK: true
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: '2.7'
21
+ bundler-cache: true
22
+
23
+ - name: Generate document
24
+ run: bundle exec bin/toolbox docgen > doc/resource_types.md
25
+
26
+ - uses: EndBug/add-and-commit@v7
27
+ with:
28
+ default_author: github_actions
29
+ add: 'doc/resource_types.md'
data/.rubocop.yml CHANGED
@@ -10,12 +10,24 @@ Layout/MultilineOperationIndentation:
10
10
  Layout/MultilineMethodCallBraceLayout:
11
11
  Enabled: false
12
12
 
13
+ Layout/ClosingHeredocIndentation:
14
+ Enabled: false
15
+
16
+ Layout/SpaceInsideArrayLiteralBrackets:
17
+ Enabled: false
18
+
13
19
  Lint/HandleExceptions:
14
20
  Enabled: false
15
21
 
16
22
  Lint/UselessAssignment:
17
23
  Enabled: false
18
24
 
25
+ Lint/DuplicateMethods:
26
+ Enabled: false
27
+
28
+ Lint/MissingCopEnableDirective:
29
+ Enabled: false
30
+
19
31
  Metrics/AbcSize:
20
32
  Max: 50
21
33
 
@@ -41,7 +53,13 @@ Metrics/ModuleLength:
41
53
  Metrics/PerceivedComplexity:
42
54
  Max: 15
43
55
 
44
- Style/PredicateName:
56
+ Naming/UncommunicativeMethodParamName:
57
+ Enabled: false
58
+
59
+ Naming/PredicateName:
60
+ Enabled: false
61
+
62
+ Naming/HeredocDelimiterNaming:
45
63
  Enabled: false
46
64
 
47
65
  Performance/StringReplacement:
@@ -65,7 +83,10 @@ Style/ClassAndModuleChildren:
65
83
  Style/Documentation:
66
84
  Enabled: false
67
85
 
68
- Style/MethodMissing:
86
+ Style/MethodMissingSuper:
87
+ Enabled: false
88
+
89
+ Style/MissingRespondToMissing:
69
90
  Enabled: false
70
91
 
71
92
  Style/MutableConstant:
@@ -91,3 +112,27 @@ Style/SymbolProc:
91
112
 
92
113
  Style/YodaCondition:
93
114
  Enabled: false
115
+
116
+ Style/RescueStandardError:
117
+ Enabled: false
118
+
119
+ Style/RedundantReturn:
120
+ Enabled: false
121
+
122
+ Style/ConditionalAssignment:
123
+ Enabled: false
124
+
125
+ Style/EvalWithLocation:
126
+ Enabled: false
127
+
128
+ Style/MixinUsage:
129
+ Exclude:
130
+ - 'lib/awspec/helper.rb'
131
+
132
+ Style/StderrPuts:
133
+ Exclude:
134
+ - 'lib/awspec/generator/template.rb'
135
+ - 'lib/awspec/setup.rb'
136
+
137
+ Style/IfUnlessModifier:
138
+ Enabled: false
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in awspec.gemspec
4
4
  gemspec
5
+
6
+ # gem 'ox' if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.0.0')
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
- # awspec [![Gem](https://img.shields.io/gem/v/awspec.svg)](https://rubygems.org/gems/awspec) [![Travis](https://img.shields.io/travis/k1LoW/awspec.svg)](https://travis-ci.org/k1LoW/awspec)
1
+ # awspec [![Gem](https://img.shields.io/gem/v/awspec.svg)](https://rubygems.org/gems/awspec) [![CI](https://github.com/k1LoW/awspec/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/awspec/actions)
2
2
 
3
3
  ![Logo](./awspec-logo.png)
4
4
 
5
5
  RSpec tests for your AWS resources.
6
6
 
7
- [![Join the chat at https://gitter.im/k1LoW/awspec](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/k1LoW/awspec?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
-
9
7
  [Resource Types](doc/resource_types.md) | [Contributing](doc/contributing.md)
10
8
 
11
9
  ## Installation
data/Rakefile CHANGED
@@ -23,7 +23,6 @@ if defined?(RSpec)
23
23
  'spec:core',
24
24
  'spec:generator_spec',
25
25
  'spec:generator_doc',
26
- 'spec:rubocop',
27
26
  'spec:helper']
28
27
 
29
28
  task type: types
data/awspec.gemspec CHANGED
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'awspec/version'
6
4
 
@@ -21,6 +19,7 @@ Gem::Specification.new do |spec|
21
19
  spec.require_paths = ['lib']
22
20
 
23
21
  spec.required_ruby_version = '>= 2.1'
22
+ spec.add_runtime_dependency 'addressable'
24
23
  spec.add_runtime_dependency 'aws-sdk', '~> 3'
25
24
  spec.add_runtime_dependency 'awsecrets', '~> 1'
26
25
  spec.add_runtime_dependency 'dry-inflector'
@@ -29,10 +28,9 @@ Gem::Specification.new do |spec|
29
28
  spec.add_runtime_dependency 'rspec-its'
30
29
  spec.add_runtime_dependency 'term-ansicolor'
31
30
  spec.add_runtime_dependency 'thor'
32
- spec.add_runtime_dependency 'addressable'
33
31
  spec.add_development_dependency 'bundler', '>= 1.9', '< 3.0'
34
32
  spec.add_development_dependency 'octorelease'
35
33
  spec.add_development_dependency 'pry'
36
34
  spec.add_development_dependency 'rake', '~> 12.0'
37
- spec.add_development_dependency 'rubocop', '~> 0.49.0'
35
+ spec.add_development_dependency 'rubocop', '~> 0.57.0'
38
36
  end
@@ -21,6 +21,15 @@ describe cloudwatch_logs('my-cloudwatch-logs-group') do
21
21
  it { should have_metric_filter('my-cloudwatch-logs-metric-filter') }
22
22
  end
23
23
  ```
24
+ or
25
+ ```ruby
26
+ describe cloudwatch_logs('my-cloudwatch-logs-group') do
27
+ it do
28
+ should have_metric_filter('my-cloudwatch-logs-metric-filter')
29
+ .filter_pattern('[date, error]')
30
+ end
31
+ end
32
+ ```
24
33
 
25
34
  ### have_subscription_filter
26
35
 
@@ -5,6 +5,25 @@ describe eks_nodegroup('my-eks-nodegroup'), cluster: 'my-cluster' do
5
5
  it { should exist }
6
6
  end
7
7
  ```
8
+
9
+ ### have_security_group
10
+
11
+ ```ruby
12
+ describe eks_nodegroup('my-eks-nodegroup'), cluster: 'my-cluster' do
13
+ it { should have_security_group('sg-1a2b3cd4') }
14
+ end
15
+ ```
16
+
17
+ ### scaling_config
18
+
19
+ ```ruby
20
+ describe eks_nodegroup('my-eks-nodegroup'), cluster: 'my-cluster' do
21
+ its('scaling_config.min_size') { should eq 1 }
22
+ its('scaling_config.desired_size') { should eq 2 }
23
+ its('scaling_config.max_size') { should eq 3 }
24
+ end
25
+ ```
26
+
8
27
  ### be_active, be_creating
9
28
 
10
29
  ```ruby
@@ -12,3 +31,37 @@ describe eks('my-eks-nodegroup'), cluster: 'my-cluster' do
12
31
  it { should be_active }
13
32
  end
14
33
  ```
34
+
35
+ ### be_ready
36
+
37
+ This matcher *might* not be exactly you are expecting: it is different from what
38
+ you can see when looking at the AWS console at the Node Groups configuration
39
+ and check if the nodes Status is "Ready".
40
+
41
+ What you seeing over there is
42
+ [actually the same thing](https://aws.amazon.com/premiumsupport/knowledge-center/eks-node-status-ready/)
43
+ you would if using `kubectl`.
44
+
45
+ This matcher cannot do the same because it would involve using the Kubernetes
46
+ API: the AWS Ruby SDK currently doesn't expose this information.
47
+
48
+ What you can get from `be_ready` matcher is asserting that you have **at least**
49
+ the number of EC2 instances (the nodes in your EKS Node Group) are actually
50
+ in running state. It doesn't mean everything is fine, the node (EC2 instance)
51
+ can be running but without communication with the cluster or any order issue
52
+ regarding the Kubernetes configuration.
53
+
54
+ Although it might look an incomplete assertion, definitely the Node Group
55
+ "Status" won't be "Active" if the EC2 instances associated with it are not
56
+ running.
57
+
58
+ So, using this assertion like the sample below:
59
+
60
+ ```ruby
61
+ describe eks('my-eks-nodegroup'), cluster: 'my-cluster' do
62
+ it { should be_ready }
63
+ end
64
+ ```
65
+
66
+ Will pass if at least the minimum expected (see `scaling_config`) number of EC2
67
+ instances are running.
@@ -678,6 +678,15 @@ describe cloudwatch_logs('my-cloudwatch-logs-group') do
678
678
  it { should have_metric_filter('my-cloudwatch-logs-metric-filter') }
679
679
  end
680
680
  ```
681
+ or
682
+ ```ruby
683
+ describe cloudwatch_logs('my-cloudwatch-logs-group') do
684
+ it do
685
+ should have_metric_filter('my-cloudwatch-logs-metric-filter')
686
+ .filter_pattern('[date, error]')
687
+ end
688
+ end
689
+ ```
681
690
 
682
691
 
683
692
  ### have_subscription_filter
@@ -836,7 +845,7 @@ describe directconnect_virtual_interface('my-directconnect-virtual-interface') d
836
845
  end
837
846
  ```
838
847
 
839
- ### its(:owner_account), its(:virtual_interface_id), its(:location), its(:connection_id), its(:virtual_interface_type), its(:virtual_interface_name), its(:vlan), its(:asn), its(:amazon_side_asn), its(:auth_key), its(:amazon_address), its(:customer_address), its(:address_family), its(:virtual_interface_state), its(:customer_router_config), its(:mtu), its(:jumbo_frame_capable), its(:virtual_gateway_id), its(:direct_connect_gateway_id), its(:route_filter_prefixes), its(:bgp_peers), its(:region), its(:aws_device_v2), its(:tags)
848
+ ### its(:owner_account), its(:virtual_interface_id), its(:location), its(:connection_id), its(:virtual_interface_type), its(:virtual_interface_name), its(:vlan), its(:asn), its(:amazon_side_asn), its(:auth_key), its(:amazon_address), its(:customer_address), its(:address_family), its(:virtual_interface_state), its(:customer_router_config), its(:mtu), its(:jumbo_frame_capable), its(:virtual_gateway_id), its(:direct_connect_gateway_id), its(:route_filter_prefixes), its(:bgp_peers), its(:region), its(:aws_device_v2), its(:aws_logical_device_id), its(:tags)
840
849
  ## <a name="dynamodb_table">dynamodb_table</a>
841
850
 
842
851
  DynamodbTable resource type.
@@ -1118,7 +1127,7 @@ end
1118
1127
  ```
1119
1128
 
1120
1129
 
1121
- ### its(:ami_launch_index), its(:image_id), its(:instance_id), its(:instance_type), its(:kernel_id), its(:key_name), its(:launch_time), its(:monitoring), its(:placement), its(:platform), its(:private_dns_name), its(:private_ip_address), its(:product_codes), its(:public_dns_name), its(:public_ip_address), its(:ramdisk_id), its(:state_transition_reason), its(:subnet_id), its(:vpc_id), its(:architecture), its(:client_token), its(:ebs_optimized), its(:ena_support), its(:hypervisor), its(:instance_lifecycle), its(:elastic_gpu_associations), its(:elastic_inference_accelerator_associations), its(:outpost_arn), its(:root_device_name), its(:root_device_type), its(:source_dest_check), its(:spot_instance_request_id), its(:sriov_net_support), its(:state_reason), its(:virtualization_type), its(:cpu_options), its(:capacity_reservation_id), its(:capacity_reservation_specification), its(:hibernation_options), its(:licenses), its(:metadata_options), its(:enclave_options), its(:boot_mode)
1130
+ ### its(:ami_launch_index), its(:image_id), its(:instance_id), its(:instance_type), its(:kernel_id), its(:key_name), its(:launch_time), its(:monitoring), its(:placement), its(:platform), its(:private_dns_name), its(:private_ip_address), its(:product_codes), its(:public_dns_name), its(:public_ip_address), its(:ramdisk_id), its(:state_transition_reason), its(:subnet_id), its(:vpc_id), its(:architecture), its(:client_token), its(:ebs_optimized), its(:ena_support), its(:hypervisor), its(:instance_lifecycle), its(:elastic_gpu_associations), its(:elastic_inference_accelerator_associations), its(:outpost_arn), its(:root_device_name), its(:root_device_type), its(:source_dest_check), its(:spot_instance_request_id), its(:sriov_net_support), its(:state_reason), its(:virtualization_type), its(:cpu_options), its(:capacity_reservation_id), its(:capacity_reservation_specification), its(:hibernation_options), its(:licenses), its(:metadata_options), its(:enclave_options), its(:boot_mode), its(:platform_details), its(:usage_operation), its(:usage_operation_update_time)
1122
1131
  ### :unlock: Advanced use
1123
1132
 
1124
1133
  `ec2` can use `Aws::EC2::Instance` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Instance.html).
@@ -1357,7 +1366,7 @@ describe eks('my-eks') do
1357
1366
  end
1358
1367
  ```
1359
1368
 
1360
- ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:kubernetes_network_config), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags), its(:encryption_config)
1369
+ ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:kubernetes_network_config), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags), its(:encryption_config), its(:connector_config)
1361
1370
  ## <a name="eks_nodegroup">eks_nodegroup</a>
1362
1371
 
1363
1372
  EksNodegroup resource type.
@@ -1370,9 +1379,53 @@ describe eks_nodegroup('my-eks-nodegroup'), cluster: 'my-cluster' do
1370
1379
  end
1371
1380
  ```
1372
1381
 
1382
+
1373
1383
  ### be_active, be_inactive
1374
1384
 
1375
- ### its(:nodegroup_name), its(:nodegroup_arn), its(:cluster_name), its(:version), its(:release_version), its(:created_at), its(:modified_at), its(:status), its(:capacity_type), its(:scaling_config), its(:instance_types), its(:subnets), its(:remote_access), its(:ami_type), its(:node_role), its(:labels), its(:taints), its(:resources), its(:disk_size), its(:health), its(:update_config), its(:launch_template), its(:tags)
1385
+ ### be_ready
1386
+
1387
+ This matcher *might* not be exactly you are expecting: it is different from what
1388
+ you can see when looking at the AWS console at the Node Groups configuration
1389
+ and check if the nodes Status is "Ready".
1390
+
1391
+ What you seeing over there is
1392
+ [actually the same thing](https://aws.amazon.com/premiumsupport/knowledge-center/eks-node-status-ready/)
1393
+ you would if using `kubectl`.
1394
+
1395
+ This matcher cannot do the same because it would involve using the Kubernetes
1396
+ API: the AWS Ruby SDK currently doesn't expose this information.
1397
+
1398
+ What you can get from `be_ready` matcher is asserting that you have **at least**
1399
+ the number of EC2 instances (the nodes in your EKS Node Group) are actually
1400
+ in running state. It doesn't mean everything is fine, the node (EC2 instance)
1401
+ can be running but without communication with the cluster or any order issue
1402
+ regarding the Kubernetes configuration.
1403
+
1404
+ Although it might look an incomplete assertion, definitely the Node Group
1405
+ "Status" won't be "Active" if the EC2 instances associated with it are not
1406
+ running.
1407
+
1408
+ So, using this assertion like the sample below:
1409
+
1410
+ ```ruby
1411
+ describe eks('my-eks-nodegroup'), cluster: 'my-cluster' do
1412
+ it { should be_ready }
1413
+ end
1414
+ ```
1415
+
1416
+ Will pass if at least the minimum expected (see `scaling_config`) number of EC2
1417
+ instances are running.
1418
+
1419
+ ### have_security_group
1420
+
1421
+ ```ruby
1422
+ describe eks_nodegroup('my-eks-nodegroup'), cluster: 'my-cluster' do
1423
+ it { should have_security_group('sg-1a2b3cd4') }
1424
+ end
1425
+ ```
1426
+
1427
+
1428
+ ### its(:nodegroup_name), its(:nodegroup_arn), its(:cluster_name), its(:version), its(:release_version), its(:created_at), its(:modified_at), its(:status), its(:capacity_type), its(:instance_types), its(:subnets), its(:remote_access), its(:ami_type), its(:node_role), its(:labels), its(:taints), its(:resources), its(:disk_size), its(:health), its(:update_config), its(:launch_template), its(:tags)
1376
1429
  ## <a name="elasticache">elasticache</a>
1377
1430
 
1378
1431
  Elasticache resource type.
@@ -2178,7 +2231,7 @@ DOC
2178
2231
  end
2179
2232
  ```
2180
2233
 
2181
- ### its(:aws_account_id), its(:key_id), its(:arn), its(:creation_date), its(:enabled), its(:description), its(:key_usage), its(:key_state), its(:deletion_date), its(:valid_to), its(:origin), its(:custom_key_store_id), its(:cloud_hsm_cluster_id), its(:expiration_model), its(:key_manager), its(:customer_master_key_spec), its(:encryption_algorithms), its(:signing_algorithms), its(:multi_region), its(:multi_region_configuration), its(:pending_deletion_window_in_days)
2234
+ ### its(:aws_account_id), its(:key_id), its(:arn), its(:creation_date), its(:enabled), its(:description), its(:key_usage), its(:key_state), its(:deletion_date), its(:valid_to), its(:origin), its(:custom_key_store_id), its(:cloud_hsm_cluster_id), its(:expiration_model), its(:key_manager), its(:customer_master_key_spec), its(:key_spec), its(:encryption_algorithms), its(:signing_algorithms), its(:multi_region), its(:multi_region_configuration), its(:pending_deletion_window_in_days)
2182
2235
  ## <a name="lambda">lambda</a>
2183
2236
 
2184
2237
  Lambda resource type.
@@ -2227,7 +2280,7 @@ end
2227
2280
 
2228
2281
  This matcher does not support Amazon S3 event sources ([see SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method)).
2229
2282
 
2230
- ### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:kms_key_arn), its(:master_arn), its(:revision_id), its(:layers), its(:state), its(:state_reason), its(:state_reason_code), its(:last_update_status), its(:last_update_status_reason), its(:last_update_status_reason_code), its(:file_system_configs), its(:package_type), its(:image_config_response), its(:signing_profile_version_arn), its(:signing_job_arn)
2283
+ ### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:kms_key_arn), its(:master_arn), its(:revision_id), its(:layers), its(:state), its(:state_reason), its(:state_reason_code), its(:last_update_status), its(:last_update_status_reason), its(:last_update_status_reason_code), its(:file_system_configs), its(:package_type), its(:image_config_response), its(:signing_profile_version_arn), its(:signing_job_arn), its(:architectures)
2231
2284
  ## <a name="launch_configuration">launch_configuration</a>
2232
2285
 
2233
2286
  LaunchConfiguration resource type.
@@ -2373,7 +2426,7 @@ end
2373
2426
 
2374
2427
  ### be_updating
2375
2428
 
2376
- ### its(:active_operation_arn), its(:client_authentication), its(:cluster_arn), its(:cluster_name), its(:creation_time), its(:current_version), its(:enhanced_monitoring), its(:number_of_broker_nodes), its(:state), its(:zookeeper_connect_string), its(:zookeeper_connect_string_tls)
2429
+ ### its(:active_operation_arn), its(:client_authentication), its(:cluster_arn), its(:cluster_name), its(:creation_time), its(:current_version), its(:enhanced_monitoring), its(:number_of_broker_nodes), its(:state), its(:state_info), its(:zookeeper_connect_string), its(:zookeeper_connect_string_tls)
2377
2430
  ## <a name="nat_gateway">nat_gateway</a>
2378
2431
 
2379
2432
  NatGateway resource type.
@@ -2573,7 +2626,7 @@ describe network_interface('eni-12ab3cde') do
2573
2626
  end
2574
2627
  ```
2575
2628
 
2576
- ### its(:association), its(:availability_zone), its(:description), its(:interface_type), its(:ipv_6_addresses), its(:mac_address), its(:network_interface_id), its(:outpost_arn), its(:owner_id), its(:private_dns_name), its(:private_ip_address), its(:requester_id), its(:requester_managed), its(:source_dest_check), its(:status), its(:subnet_id), its(:vpc_id)
2629
+ ### its(:association), its(:availability_zone), its(:description), its(:interface_type), its(:ipv_6_addresses), its(:mac_address), its(:network_interface_id), its(:outpost_arn), its(:owner_id), its(:private_dns_name), its(:private_ip_address), its(:ipv_4_prefixes), its(:ipv_6_prefixes), its(:requester_id), its(:requester_managed), its(:source_dest_check), its(:status), its(:subnet_id), its(:vpc_id)
2577
2630
  ## <a name="nlb">nlb</a>
2578
2631
 
2579
2632
  NLB resource type.
@@ -2801,7 +2854,7 @@ end
2801
2854
  ```
2802
2855
 
2803
2856
 
2804
- ### its(:vpc_id), its(:db_instance_identifier), its(:db_instance_class), its(:engine), its(:db_instance_status), 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)
2857
+ ### 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)
2805
2858
  ### :unlock: Advanced use
2806
2859
 
2807
2860
  `rds` can use `Aws::RDS::DBInstance` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/DBInstance.html).
@@ -3515,7 +3568,7 @@ end
3515
3568
  ```
3516
3569
 
3517
3570
 
3518
- ### its(:availability_zone), its(:availability_zone_id), its(:available_ip_address_count), its(:cidr_block), its(:default_for_az), its(:map_public_ip_on_launch), its(:map_customer_owned_ip_on_launch), its(:customer_owned_ipv_4_pool), its(:state), its(:subnet_id), its(:vpc_id), its(:owner_id), its(:assign_ipv_6_address_on_creation), its(:ipv_6_cidr_block_association_set), its(:subnet_arn), its(:outpost_arn)
3571
+
3519
3572
  ### :unlock: Advanced use
3520
3573
 
3521
3574
  `subnet` can use `Aws::EC2::Subnet` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Subnet.html).
@@ -51,7 +51,7 @@ module Awspec
51
51
  types_for_generate_all = %w(
52
52
  cloudwatch_alarm cloudwatch_event directconnect ebs efs
53
53
  elasticsearch iam_group iam_policy iam_role iam_user kms lambda
54
- acm cloudwatch_logs eip codebuild
54
+ acm cloudwatch_logs eip codebuild elasticache
55
55
  )
56
56
 
57
57
  types_for_generate_all.each do |type|
@@ -23,7 +23,11 @@ module Awspec::Generator
23
23
  metric_filters = select_all_cloudwatch_logs_metric_filter(log_group)
24
24
  metric_filter_lines = []
25
25
  metric_filters.each do |metric_filter|
26
- line = "it { should have_metric_filter('#{metric_filter.filter_name}') }"
26
+ line = "it { should have_metric_filter('#{metric_filter.filter_name}')"
27
+ unless metric_filter.filter_pattern.empty?
28
+ line += ".filter_pattern('#{metric_filter.filter_pattern}')"
29
+ end
30
+ line += ' }'
27
31
  metric_filter_lines.push(line)
28
32
  end
29
33
  metric_filter_lines
@@ -0,0 +1,43 @@
1
+ module Awspec::Generator
2
+ module Spec
3
+ class Elasticache
4
+ include Awspec::Helper::Finder
5
+ def generate_all
6
+ opt = {}
7
+ clusters = []
8
+ loop do
9
+ res = elasticache_client.describe_cache_clusters(opt)
10
+ clusters.push(*res.cache_clusters)
11
+ break if res.marker.nil?
12
+ opt = { marker: res.marker }
13
+ end
14
+ raise 'Not Found Cache Clusters' if clusters.empty?
15
+ ERB.new(cache_clusters_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
16
+ end
17
+
18
+ def cache_clusters_spec_template
19
+ template = <<-'EOF'
20
+ <% clusters.each do |cluster| %>
21
+ describe elasticache('<%= cluster.cache_cluster_id %>') do
22
+ it { should exist }
23
+ it { should be_available }
24
+ it { should have_cache_parameter_group('<%= cluster.cache_parameter_group.cache_parameter_group_name %>') }
25
+ it { should belong_to_cache_subnet_group('<%= cluster.cache_subnet_group_name %>') }
26
+ <% unless cluster.replication_group_id.nil? %>
27
+ its(:replication_group_id) { should eq '<%= cluster.replication_group_id %>' }
28
+ <% end %>
29
+ its(:engine) { should eq '<%= cluster.engine %>' }
30
+ its(:engine_version) { should eq '<%= cluster.engine_version %>' }
31
+ its(:cache_node_type) { should eq '<%= cluster.cache_node_type %>' }
32
+ <% unless cluster.snapshot_retention_limit.nil? %>
33
+ its(:snapshot_retention_limit) { should eq <%= cluster.snapshot_retention_limit %> }
34
+ its(:snapshot_window) { should eq '<%= cluster.snapshot_window %>' }
35
+ <% end %>
36
+ end
37
+ <% end %>
38
+ EOF
39
+ template
40
+ end
41
+ end
42
+ end
43
+ end
@@ -27,6 +27,7 @@ require 'awspec/generator/spec/cloudwatch_logs'
27
27
  require 'awspec/generator/spec/alb'
28
28
  require 'awspec/generator/spec/nlb'
29
29
  require 'awspec/generator/spec/internet_gateway'
30
+ require 'awspec/generator/spec/elasticache'
30
31
  require 'awspec/generator/spec/elasticsearch'
31
32
  require 'awspec/generator/spec/eip'
32
33
  require 'awspec/generator/spec/rds_db_parameter_group'
@@ -3,24 +3,48 @@ module Awspec::Helper
3
3
  module Ec2
4
4
  def find_ec2(id)
5
5
  # instance_id or tag:Name
6
- begin
7
- res = ec2_client.describe_instances({
8
- instance_ids: [id]
9
- })
10
- rescue Aws::EC2::Errors::InvalidInstanceIDNotFound, Aws::EC2::Errors::InvalidInstanceIDMalformed => e
11
- res = ec2_client.describe_instances({
12
- filters: [{ name: 'tag:Name', values: [id] }]
13
- })
14
- end
15
- # rubocop:enable Style/GuardClause
16
-
17
- if res.reservations.count == 0
18
- nil
19
- elsif res.reservations.count == 1
20
- res.reservations.first.instances.single_resource(id)
21
- elsif res.reservations.count > 1
22
- raise Awspec::DuplicatedResourceTypeError, "Duplicate instances matching id or tag #{id}"
6
+
7
+ # First tries to search by using an educated guess, based on the
8
+ # references below:
9
+ # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/resource-ids.html
10
+ # https://docs.chef.io/inspec/resources/aws_ec2_instance/
11
+ # This should be faster then just first trying ID when the parameter is
12
+ # clearly not one
13
+
14
+ # https://medium.com/@Bakku1505/ruby-start-with-end-with-vs-regular-expressions-59728be0859e
15
+ if id.start_with?('i-') && id.length == 19 && id =~ /^i-[0-9a-f]/
16
+ begin
17
+ res = ec2_client.describe_instances({
18
+ instance_ids: [id]
19
+ })
20
+ rescue Aws::EC2::Errors::InvalidInstanceIDNotFound, Aws::EC2::Errors::InvalidInstanceIDMalformed => e
21
+ res = ec2_client.describe_instances({
22
+ filters: [{ name: 'tag:Name', values: [id] }]
23
+ })
24
+ end
25
+ else
26
+ begin
27
+ res = ec2_client.describe_instances({
28
+ filters: [{ name: 'tag:Name', values: [id] }]
29
+ })
30
+ rescue Aws::EC2::Errors::InvalidInstanceIDNotFound, Aws::EC2::Errors::InvalidInstanceIDMalformed => e
31
+ res = ec2_client.describe_instances({
32
+ instance_ids: [id]
33
+ })
34
+ if res.reservations.count > 1
35
+ STDERR.puts "Warning: '#{id}' unexpectedly identified as a valid instance ID during fallback search"
36
+ end
37
+ end
23
38
  end
39
+
40
+ return nil if res.reservations.count == 0
41
+ return res.reservations.first.instances.single_resource(id) if res.reservations.count == 1
42
+ raise Awspec::DuplicatedResourceTypeError, dup_ec2_instance(id) if res.reservations.count > 1
43
+ raise "Unexpected condition of having reservations = #{res.reservations.count}"
44
+ end
45
+
46
+ def dup_ec2_instance(id)
47
+ "Duplicate instances matching id or tag #{id}"
24
48
  end
25
49
 
26
50
  def find_ec2_attribute(id, attribute)
@@ -36,7 +36,7 @@ module Awspec::Helper
36
36
  # deprecated method
37
37
  def find_ecs_container_instances(cluster, container_instances)
38
38
  res = ecs_client.describe_container_instances(cluster: cluster, container_instances: container_instances)
39
- res.container_instances if res.container_instances
39
+ res.container_instances if res.container_instances # rubocop:disable Style/UnneededCondition
40
40
  end
41
41
 
42
42
  alias_method :list_ecs_container_instances, :select_ecs_container_instance_arn_by_cluster_name # deprecated method