awspec 1.18.4 → 1.19.2

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: 8620c43be44ef78d4639f850333575db607268b9215a7d237437650430dc33d4
4
- data.tar.gz: 3b456a4446cefbfc87e0f3e5fb01e0fb622d1f3251ef671462c50362e395aff8
3
+ metadata.gz: 0cb0f518cbb9a6fd1719a6ab94547039f8ce88140d1a3536f47813f2c1de866a
4
+ data.tar.gz: 7ac384fb88ba40da139ba7ff562b17b93c2000a89dada4011ad9a3eeda64976a
5
5
  SHA512:
6
- metadata.gz: 37dee8d4d020de491b58a5692fcbe0e57fcb20e06387a3ce87dbe7a49cd7402bf5f40331bdff30edc4a43f12b40a1f03d67ca7c6479adfe9829e007acc17c846
7
- data.tar.gz: c65aaa6acbdb108164cc56de46b5d0ff0f5fecf73f398b7f3c865c04037e3de18f9fe8d7c6497e63396dfef2fbd4071789bf964d4802f56ebce3a0241c3ff8e4
6
+ metadata.gz: 027a2d063404ce032e2257d01e520a142152e81c33118d69a8a1a2f8defc9667b50f45362bc9051ef6e08594f47d4d9cc2fcafb64b508ce9e023bbd01a61701f
7
+ data.tar.gz: ad59add2cf039e0e2371b96899106f970c1d0a64ef3a0aca81f54af7f9fa9c5253563cad3772e1579f88837fe227ce34fe5de1cc23c3eba48f4eec8f56d080f8
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'rspec-its'
30
30
  spec.add_runtime_dependency 'term-ansicolor'
31
31
  spec.add_runtime_dependency 'thor'
32
+ spec.add_runtime_dependency 'addressable'
32
33
  spec.add_development_dependency 'bundler', '>= 1.9', '< 3.0'
33
34
  spec.add_development_dependency 'octorelease'
34
35
  spec.add_development_dependency 'pry'
@@ -198,7 +198,7 @@ describe alb_listener('arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:li
198
198
  end
199
199
  ```
200
200
 
201
- ### its(:listener_arn), its(:load_balancer_arn), its(:port), its(:protocol), its(:certificates), its(:ssl_policy)
201
+ ### its(:listener_arn), its(:load_balancer_arn), its(:port), its(:protocol), its(:certificates), its(:ssl_policy), its(:alpn_policy)
202
202
  ## <a name="alb_target_group">alb_target_group</a>
203
203
 
204
204
  AlbTargetGroup resource type.
@@ -267,7 +267,7 @@ end
267
267
 
268
268
  ### have_tag
269
269
 
270
- ### its(:architecture), its(:creation_date), its(:image_id), its(:image_location), its(:image_type), its(:public), its(:kernel_id), its(:owner_id), its(:platform), its(:ramdisk_id), its(:state), its(:description), its(:ena_support), its(:hypervisor), its(:image_owner_alias), its(:name), its(:root_device_name), its(:root_device_type), its(:sriov_net_support), its(:state_reason), its(:virtualization_type)
270
+ ### its(:architecture), its(:creation_date), its(:image_id), its(:image_location), its(:image_type), its(:public), its(:kernel_id), its(:owner_id), its(:platform), its(:platform_details), its(:usage_operation), its(:ramdisk_id), its(:state), its(:description), its(:ena_support), its(:hypervisor), its(:image_owner_alias), its(:name), its(:root_device_name), its(:root_device_type), its(:sriov_net_support), its(:state_reason), its(:virtualization_type)
271
271
  ### :unlock: Advanced use
272
272
 
273
273
  `ami` can use `Aws::EC2::Image` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Image.html).
@@ -284,6 +284,14 @@ describe apigateway('my-apigateway') do
284
284
  end
285
285
  ```
286
286
 
287
+ ### have_integration_method
288
+
289
+ ### have_integration_path
290
+
291
+ ### have_method
292
+
293
+ ### have_path
294
+
287
295
  ### its(:id), its(:name), its(:description), its(:created_date), its(:version), its(:warnings), its(:binary_media_types), its(:minimum_compression_size), its(:api_key_source), its(:policy), its(:tags)
288
296
  ## <a name="autoscaling_group">autoscaling_group</a>
289
297
 
@@ -894,7 +902,7 @@ end
894
902
  ```
895
903
 
896
904
 
897
- ### its(:availability_zone), its(:create_time), its(:encrypted), its(:kms_key_id), its(:outpost_arn), its(:size), its(:snapshot_id), its(:state), its(:volume_id), its(:iops), its(:volume_type), its(:fast_restored)
905
+ ### its(:availability_zone), its(:create_time), its(:encrypted), its(:kms_key_id), its(:outpost_arn), its(:size), its(:snapshot_id), its(:state), its(:volume_id), its(:iops), its(:volume_type), its(:fast_restored), its(:multi_attach_enabled)
898
906
  ### :unlock: Advanced use
899
907
 
900
908
  `ebs` can use `Aws::EC2::Volume` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Volume.html).
@@ -1319,7 +1327,7 @@ describe eks('my-eks') do
1319
1327
  end
1320
1328
  ```
1321
1329
 
1322
- ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags)
1330
+ ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags), its(:encryption_config)
1323
1331
  ## <a name="elasticache">elasticache</a>
1324
1332
 
1325
1333
  Elasticache resource type.
@@ -1388,7 +1396,7 @@ describe elasticache('my-rep-group-001') do
1388
1396
  end
1389
1397
  ```
1390
1398
 
1391
- ### its(:cache_cluster_id), its(:configuration_endpoint), its(:client_download_landing_page), its(:cache_node_type), its(:engine), its(:engine_version), its(:cache_cluster_status), its(:num_cache_nodes), its(:preferred_availability_zone), its(:cache_cluster_create_time), its(:preferred_maintenance_window), its(:notification_configuration), its(:cache_security_groups), its(:cache_subnet_group_name), its(:cache_nodes), its(:auto_minor_version_upgrade), its(:replication_group_id), its(:snapshot_retention_limit), its(:snapshot_window), its(:auth_token_enabled), its(:auth_token_last_modified_date), its(:transit_encryption_enabled), its(:at_rest_encryption_enabled)
1399
+ ### its(:cache_cluster_id), its(:configuration_endpoint), its(:client_download_landing_page), its(:cache_node_type), its(:engine), its(:engine_version), its(:cache_cluster_status), its(:num_cache_nodes), its(:preferred_availability_zone), its(:cache_cluster_create_time), its(:preferred_maintenance_window), its(:notification_configuration), its(:cache_security_groups), its(:cache_subnet_group_name), its(:cache_nodes), its(:auto_minor_version_upgrade), its(:replication_group_id), its(:snapshot_retention_limit), its(:snapshot_window), its(:auth_token_enabled), its(:auth_token_last_modified_date), its(:transit_encryption_enabled), its(:at_rest_encryption_enabled), its(:arn)
1392
1400
  ## <a name="elasticache_cache_parameter_group">elasticache_cache_parameter_group</a>
1393
1401
 
1394
1402
  ElasticacheCacheParameterGroup resource type.
@@ -1467,7 +1475,7 @@ end
1467
1475
  ```
1468
1476
 
1469
1477
 
1470
- ### its(:domain_id), its(:domain_name), its(:arn), its(:created), its(:deleted), its(:endpoint), its(:endpoints), its(:processing), its(:upgrade_processing), its(:elasticsearch_version), its(:access_policies), its(:snapshot_options), its(:vpc_options), its(:cognito_options), its(:encryption_at_rest_options), its(:node_to_node_encryption_options), its(:advanced_options), its(:log_publishing_options), its(:service_software_options), its(:domain_endpoint_options)
1478
+ ### its(:domain_id), its(:domain_name), its(:arn), its(:created), its(:deleted), its(:endpoint), its(:endpoints), its(:processing), its(:upgrade_processing), its(:elasticsearch_version), its(:access_policies), its(:snapshot_options), its(:vpc_options), its(:cognito_options), its(:encryption_at_rest_options), its(:node_to_node_encryption_options), its(:advanced_options), its(:log_publishing_options), its(:service_software_options), its(:domain_endpoint_options), its(:advanced_security_options)
1471
1479
  ## <a name="elastictranscoder_pipeline">elastictranscoder_pipeline</a>
1472
1480
 
1473
1481
  ElastictranscoderPipeline resource type.
@@ -1612,7 +1620,7 @@ describe emr('my-emr') do
1612
1620
  end
1613
1621
  ```
1614
1622
 
1615
- ### its(:id), its(:name), its(:instance_collection_type), its(:log_uri), its(:requested_ami_version), its(:running_ami_version), its(:release_label), its(:auto_terminate), its(:termination_protected), its(:visible_to_all_users), its(:service_role), its(:normalized_instance_hours), its(:master_public_dns_name), its(:configurations), its(:security_configuration), its(:auto_scaling_role), its(:scale_down_behavior), its(:custom_ami_id), its(:ebs_root_volume_size), its(:repo_upgrade_on_boot), its(:cluster_arn), its(:step_concurrency_level), its(:outpost_arn)
1623
+ ### its(:id), its(:name), its(:instance_collection_type), its(:log_uri), its(:log_encryption_kms_key_id), its(:requested_ami_version), its(:running_ami_version), its(:release_label), its(:auto_terminate), its(:termination_protected), its(:visible_to_all_users), its(:service_role), its(:normalized_instance_hours), its(:master_public_dns_name), its(:configurations), its(:security_configuration), its(:auto_scaling_role), its(:scale_down_behavior), its(:custom_ami_id), its(:ebs_root_volume_size), its(:repo_upgrade_on_boot), its(:cluster_arn), its(:outpost_arn), its(:step_concurrency_level)
1616
1624
  ## <a name="firehose">firehose</a>
1617
1625
 
1618
1626
  Firehose resource type.
@@ -2583,7 +2591,7 @@ describe nlb_listener('arn:aws:elasticloadbalancing:ap-northeast-1:1234567890:li
2583
2591
  end
2584
2592
  ```
2585
2593
 
2586
- ### its(:listener_arn), its(:load_balancer_arn), its(:port), its(:protocol), its(:certificates), its(:ssl_policy)
2594
+ ### its(:listener_arn), its(:load_balancer_arn), its(:port), its(:protocol), its(:certificates), its(:ssl_policy), its(:alpn_policy)
2587
2595
  ## <a name="nlb_target_group">nlb_target_group</a>
2588
2596
 
2589
2597
  NlbTargetGroup resource type.
@@ -3192,6 +3200,10 @@ end
3192
3200
 
3193
3201
  ### be_outbound_opened_only
3194
3202
 
3203
+ ### have_inbound_rule
3204
+
3205
+ ### have_outbound_rule
3206
+
3195
3207
  ### have_tag
3196
3208
 
3197
3209
  ```ruby
@@ -3381,7 +3393,7 @@ end
3381
3393
  ```
3382
3394
 
3383
3395
 
3384
- ### its(:name), its(:type), its(:key_id), its(:last_modified_date), its(:last_modified_user), its(:description), its(:allowed_pattern), its(:version), its(:tier), its(:policies)
3396
+ ### its(:name), its(:type), its(:key_id), its(:last_modified_date), its(:last_modified_user), its(:description), its(:allowed_pattern), its(:version), its(:tier), its(:policies), its(:data_type)
3385
3397
  ### :unlock: Advanced use
3386
3398
 
3387
3399
  ```ruby
@@ -3425,7 +3437,7 @@ end
3425
3437
  ```
3426
3438
 
3427
3439
 
3428
- ### 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(: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)
3440
+ ### 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)
3429
3441
  ### :unlock: Advanced use
3430
3442
 
3431
3443
  `subnet` can use `Aws::EC2::Subnet` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Subnet.html).
@@ -2,7 +2,7 @@ require 'awspec/config'
2
2
 
3
3
  module Awspec::Helper
4
4
  class ClientWrap
5
- attr_reader :client, :backoff, :iteration, :backoff_limit, :symbol
5
+ attr_reader :client, :backoff, :iteration, :backoff_limit, :symbol1, :symbol2
6
6
  def initialize(real_client = nil)
7
7
  raise ArgumentError, 'Client can not be nil' if real_client.nil?
8
8
  config = Awspec::Config.instance
@@ -14,7 +14,8 @@ module Awspec::Helper
14
14
  @backoff_limit = config[:client_backoff_limit]
15
15
  # build the symbol we'll use to compare to any errors caught in method_missing
16
16
  # below.
17
- @symbol = real_client.class.to_s.split('::').shift(2).push('Errors', 'RequestLimitExceeded').join('::').to_sym
17
+ @symbol1 = real_client.class.to_s.split('::').shift(2).push('Errors', 'RequestLimitExceeded').join('::').to_sym
18
+ @symbol2 = real_client.class.to_s.split('::').shift(2).push('Errors', 'Throttling').join('::').to_sym
18
19
  end
19
20
 
20
21
  protected
@@ -28,7 +29,7 @@ module Awspec::Helper
28
29
  begin
29
30
  results = client.send(m, *args, &block)
30
31
  rescue Exception => e # rubocop:disable Lint/RescueException
31
- raise unless e.class.to_s == symbol.to_s && backoff < backoff_limit
32
+ raise unless (e.class.to_s == symbol1.to_s || e.class.to_s == symbol2.to_s) && backoff < backoff_limit
32
33
 
33
34
  @backoff = backoff + (iteration * iteration * 0.5)
34
35
  @iteration += 1
@@ -3,8 +3,8 @@ module Awspec::Helper
3
3
  module Acm
4
4
  def find_certificate(id)
5
5
  selected = []
6
+ req = {}
6
7
  loop do
7
- req = {}
8
8
  res = acm_client.list_certificates(req)
9
9
  selected += res.certificate_summary_list.select do |c|
10
10
  c.certificate_arn == id || c.domain_name == id
@@ -19,8 +19,8 @@ module Awspec::Helper
19
19
 
20
20
  def select_all_certificates
21
21
  certs = []
22
+ req = {}
22
23
  loop do
23
- req = {}
24
24
  res = acm_client.list_certificates(req)
25
25
  res.certificate_summary_list.each do |c|
26
26
  certs << c.certificate_arn
@@ -6,7 +6,7 @@ module Awspec::Helper
6
6
  res.load_balancers.select do |lb|
7
7
  lb.type == 'application'
8
8
  end.single_resource(id)
9
- rescue
9
+ rescue Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound
10
10
  return nil
11
11
  end
12
12
 
@@ -20,7 +20,7 @@ module Awspec::Helper
20
20
  def find_alb_listener(arn)
21
21
  res = elbv2_client.describe_listeners({ listener_arns: [arn] })
22
22
  res.listeners.single_resource(arn)
23
- rescue
23
+ rescue StandardError
24
24
  return nil
25
25
  end
26
26
 
@@ -40,7 +40,7 @@ module Awspec::Helper
40
40
  res.target_groups.select do |tg|
41
41
  %w(HTTP HTTPS).include?(tg.protocol)
42
42
  end.single_resource(id)
43
- rescue
43
+ rescue StandardError
44
44
  return nil
45
45
  end
46
46
 
@@ -60,7 +60,7 @@ module Awspec::Helper
60
60
  res.tag_descriptions.select do |resource|
61
61
  resource.resource_arn == id
62
62
  end.first.tags
63
- rescue
63
+ rescue StandardError
64
64
  return nil
65
65
  end
66
66
  end
@@ -2,20 +2,34 @@ module Awspec::Helper
2
2
  module Finder
3
3
  module Apigateway
4
4
  def find_apigateway_by_id(id)
5
- rest_apis = apigateway_client.get_rest_apis
6
- rest_apis.items.each do |item|
7
- return item if item.id == id
5
+ apis = []
6
+ apigateway_client.get_rest_apis(limit: 500).each do |response|
7
+ apis += response.items
8
+ end
9
+ apis.each do |api|
10
+ return api if api.id == id
8
11
  end
9
12
  nil
10
13
  end
11
14
 
12
15
  def find_apigateway_by_name(name)
13
- rest_apis = apigateway_client.get_rest_apis
14
- rest_apis.items.each do |item|
15
- return item if item.name == name
16
+ apis = []
17
+ apigateway_client.get_rest_apis(limit: 500).each do |response|
18
+ apis += response.items
19
+ end
20
+ apis.each do |api|
21
+ return api if api.name == name
16
22
  end
17
23
  nil
18
24
  end
25
+
26
+ def find_api_resources_by_id(api_id)
27
+ all_resources = []
28
+ apigateway_client.get_resources(rest_api_id: api_id, limit: 500, embed: ['methods']).each do |response|
29
+ all_resources += response.items
30
+ end
31
+ all_resources != [] ? all_resources : nil
32
+ end
19
33
  end
20
34
  end
21
35
  end
@@ -70,6 +70,45 @@ Aws.config[:apigateway] = {
70
70
  }
71
71
  }
72
72
  ]
73
+ },
74
+ get_resources: {
75
+ position: '1',
76
+ items: [
77
+ {
78
+ path: '/proxy',
79
+ resource_methods: {
80
+ 'GET' => {
81
+ http_method: 'GET',
82
+ method_integration: { http_method: 'POST', uri: 'http://127.0.0.1:8080/hockey' }
83
+ }
84
+ }
85
+ },
86
+ {
87
+ path: '/zambonis',
88
+ resource_methods: {
89
+ 'POST' => {
90
+ http_method: 'POST',
91
+ method_integration: { http_method: 'POST',
92
+ uri: 'http://127.0.0.1:8080/zambonis/{arena}?arena=Saddledome' }
93
+ }
94
+ }
95
+ },
96
+ {
97
+ path: '/zambonis/123',
98
+ resource_methods: {
99
+ 'POST' => {
100
+ http_method: 'POST',
101
+ method_integration: { http_method: 'AWS',
102
+ uri: 'arn:aws:apigateway:us-east-1:cognito-idp:action/ListUsers' }
103
+ },
104
+ 'GET' => {
105
+ http_method: 'GET',
106
+ method_integration: { http_method: 'AWS',
107
+ uri: 'arn:aws:apigateway:us-east-1:cognito-idp:action/SignUp?username=test' }
108
+ }
109
+ }
110
+ }
111
+ ]
73
112
  }
74
113
  }
75
114
  }
@@ -15,11 +15,13 @@ module Awspec::Type
15
15
 
16
16
  STATES.each do |state|
17
17
  define_method state + '?' do
18
+ check_existence
18
19
  resource_via_client.state.code == state
19
20
  end
20
21
  end
21
22
 
22
23
  def has_security_group?(sg_id)
24
+ check_existence
23
25
  sgs = resource_via_client.security_groups
24
26
  ret = sgs.find do |sg|
25
27
  sg == sg_id
@@ -31,6 +33,7 @@ module Awspec::Type
31
33
  end
32
34
 
33
35
  def has_subnet?(subnet_id)
36
+ check_existence
34
37
  azs = resource_via_client.availability_zones
35
38
  ret = azs.find do |az|
36
39
  az.subnet_id == subnet_id
@@ -1,3 +1,5 @@
1
+ require 'addressable/uri'
2
+
1
3
  module Awspec::Type
2
4
  class Apigateway < ResourceBase
3
5
  aws_resource Aws::APIGateway::Client
@@ -11,5 +13,53 @@ module Awspec::Type
11
13
  def id
12
14
  @id ||= resource_via_client.id if resource_via_client
13
15
  end
16
+
17
+ def api_resources
18
+ @api_resources.nil? ? @api_resources = find_api_resources_by_id(@id) : @api_resources
19
+ end
20
+
21
+ def has_path?(path)
22
+ check_existence
23
+ self.api_resources.each do |resource|
24
+ return resource if resource.path == path
25
+ end
26
+ nil
27
+ end
28
+
29
+ def has_integration_path?(path)
30
+ check_existence
31
+ self.api_resources.each do |resource|
32
+ next if resource.resource_methods.nil?
33
+ resource.resource_methods.each do |_, method|
34
+ if method.method_integration.http_method == 'AWS'
35
+ aws_path = method.method_integration.uri.match(%r{(\/[^\?]+)\??.*$}).captures[0] # Matches for ARN type path
36
+ return resource if aws_path == path
37
+ end
38
+ uri = Addressable::URI.parse(method.method_integration.uri)
39
+ return resource if uri.path == path
40
+ end
41
+ end
42
+ nil
43
+ end
44
+
45
+ def has_method?(path, http_method)
46
+ check_existence
47
+ resource_to_check = has_path?(path)
48
+ return nil if resource_to_check.nil?
49
+ resource_to_check.resource_methods.each do |_, method|
50
+ return resource_to_check if method.http_method == http_method
51
+ end
52
+ nil
53
+ end
54
+
55
+ def has_integration_method?(integration_path, http_method)
56
+ check_existence
57
+ integration_resource_to_check = has_integration_path?(integration_path)
58
+ return nil if integration_resource_to_check.nil?
59
+ integration_resource_to_check.resource_methods.each do |_, method|
60
+ return integration_resource_to_check if method.method_integration.http_method == http_method
61
+ end
62
+ nil
63
+ end
14
64
  end
15
65
  end
@@ -1,4 +1,5 @@
1
1
  module Awspec::Type
2
+ # rubocop:disable Metrics/ClassLength
2
3
  class SecurityGroup < ResourceBase
3
4
  aws_resource Aws::EC2::SecurityGroup
4
5
  tags_allowed
@@ -75,12 +76,24 @@ module Awspec::Type
75
76
  end
76
77
  alias_method :outbound_permissions_count, :ip_permissions_egress_count
77
78
 
79
+ def has_inbound_rule?(rule)
80
+ resource_via_client.ip_permissions.find do |permission|
81
+ sg_rule_match?(permission, rule)
82
+ end
83
+ end
84
+
78
85
  def inbound_rule_count
79
86
  resource_via_client.ip_permissions.reduce(0) do |sum, permission|
80
87
  sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
81
88
  end
82
89
  end
83
90
 
91
+ def has_outbound_rule?(rule)
92
+ resource_via_client.ip_permissions_egress.find do |permission|
93
+ sg_rule_match?(permission, rule)
94
+ end
95
+ end
96
+
84
97
  def outbound_rule_count
85
98
  resource_via_client.ip_permissions_egress.reduce(0) do |sum, permission|
86
99
  sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
@@ -144,5 +157,36 @@ module Awspec::Type
144
157
  port.between?(from_port, to_port)
145
158
  end
146
159
  end
160
+
161
+ def sg_rule_match?(permission, rule)
162
+ rule[:ip_protocol] = '-1' if rule[:ip_protocol] == 'all'
163
+ return false unless permission.ip_protocol == rule[:ip_protocol]
164
+ return false unless permission.ip_protocol == '-1' || permission.from_port == rule[:from_port]
165
+ return false unless permission.ip_protocol == '-1' || permission.to_port == rule[:to_port]
166
+
167
+ if rule[:ip_range]
168
+ return false unless permission.ip_ranges.find do |ip_range|
169
+ ip_range.cidr_ip == rule[:ip_range]
170
+ end
171
+ elsif rule[:group_pair]
172
+ return false unless permission.user_id_group_pairs.find do |pair|
173
+ group_pair_match?(pair, rule[:group_pair])
174
+ end
175
+ end
176
+ true
177
+ end
178
+
179
+ def group_pair_match?(actual_pair, rule_pair)
180
+ return false unless actual_pair.group_id == rule_pair[:group_id] || rule_pair[:group_id].nil?
181
+ return false unless actual_pair.group_name == rule_pair[:group_name] || rule_pair[:group_name].nil?
182
+ return false unless actual_pair.user_id == rule_pair[:user_id] || rule_pair[:user_id].nil?
183
+ return false unless actual_pair.vpc_id == rule_pair[:vpc_id] || rule_pair[:vpc_id].nil?
184
+ return false unless
185
+ actual_pair.vpc_peering_connection_id == rule_pair[:vpc_peering_connection_id] ||
186
+ rule_pair[:vpc_peering_connection_id].nil?
187
+ return false unless actual_pair.peering_status == rule_pair[:peering_status] || rule_pair[:peering_status].nil?
188
+ true
189
+ end
147
190
  end
191
+ # rubocop:enable Metrics/ClassLength
148
192
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.18.4'
2
+ VERSION = '1.19.2'
3
3
  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.18.4
4
+ version: 1.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-26 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: addressable
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement