cmonson_2ndwatch_awspec 0.85.3 → 0.85.4

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
  SHA1:
3
- metadata.gz: 33dd8bac9f0d77278e8035e0549e1bd4dc4e5814
4
- data.tar.gz: ece45fb9449e43744ff3c47d6e90cb42387343ad
3
+ metadata.gz: 7747322ebc0dcafa322102975d550714433fe847
4
+ data.tar.gz: 85c21fb4deedc086a7700100265adf07a292f49c
5
5
  SHA512:
6
- metadata.gz: 53a1c30eae2150e96c0c6b64006f4ea9a5901c3137b87bc358d8a2695df696d52784eba7c7e4f7e1cdef53df8ea261c9f9bf5c306aa6a0da9ac3afbededc6dfa
7
- data.tar.gz: c6091ecc71cd490195dc290f348704be64c51cab1eb1ec72fec8efdcbb4a83da44220ec676f7fbffe9b878a8a579db63d4ef281ec9c679bad9e98bb7942b8059
6
+ metadata.gz: 5f0d4dedbf7eae02c6f95d7541ea7480e842d1d48a295a32828e8e8a651c75034513dcbec7a1996317dbe2eab5e45bf6e6e2be719cacd08b445ff53c3c4ec007
7
+ data.tar.gz: b091a6d2e44a93ae4469515060499185665fd417b7811213210cebd2bcf4d8fe51080d24215b7e240daffde26315b013eae3495eacc5b71d831dbf917827e727
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
  /tmp/
9
9
  /spec/secrets.yml
10
10
  /.ruby-version
11
+ *.sw*
12
+ *.gem
data/Rakefile CHANGED
@@ -23,7 +23,8 @@ if defined?(RSpec)
23
23
  'spec:core',
24
24
  'spec:generator_spec',
25
25
  'spec:generator_doc',
26
- 'spec:rubocop']
26
+ 'spec:rubocop',
27
+ 'spec:helper']
27
28
 
28
29
  task type: types
29
30
 
@@ -49,6 +50,10 @@ if defined?(RSpec)
49
50
  t.pattern = 'spec/generator/doc/*_spec.rb'
50
51
  end
51
52
 
53
+ RSpec::Core::RakeTask.new(:helper) do |t|
54
+ t.pattern = 'spec/lib/awspec/helper/*_spec.rb'
55
+ end
56
+
52
57
  RuboCop::RakeTask.new
53
58
  end
54
59
  end
@@ -515,7 +515,7 @@ describe cloudwatch_logs('my-cloudwatch-logs-group') do
515
515
  end
516
516
  ```
517
517
 
518
- ### its(:log_group_name), its(:creation_time), its(:retention_in_days), its(:metric_filter_count), its(:arn), its(:stored_bytes)
518
+ ### its(:log_group_name), its(:creation_time), its(:retention_in_days), its(:metric_filter_count), its(:arn), its(:stored_bytes), its(:kms_key_id)
519
519
  ## <a name="customer_gateway">customer_gateway</a>
520
520
 
521
521
  CustomerGateway resource type.
@@ -1974,7 +1974,7 @@ end
1974
1974
  ```
1975
1975
 
1976
1976
 
1977
- ### 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(:license_model), its(:iops), its(: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)
1977
+ ### 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(:license_model), its(:iops), its(: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)
1978
1978
  ### :unlock: Advanced use
1979
1979
 
1980
1980
  `rds` can use `Aws::RDS::DBInstance` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/DBInstance.html).
@@ -0,0 +1,46 @@
1
+ module Awspec::Helper
2
+ class ClientWrap
3
+ attr_reader :client, :backoff, :iteration, :backoff_limit, :symbol
4
+ def initialize(real_client = nil, args = {})
5
+ raise ArgumentError, 'Client can not be nil' if real_client.nil?
6
+ @client = real_client
7
+ @backoff = args.key?(:backoff) ? args[:backoff] : 0.0
8
+ @orig_backoff = @backoff
9
+ @iteration = args.key?(:iteration) ? args[:iteration] : 1
10
+ @orig_iter = @iteration
11
+ @backoff_limit = args.key?(:backoff_limit) ? args[:backoff_limit] : 30.0
12
+ # build the symbol we'll use to compare to any errors caught in method_missing
13
+ # below.
14
+ @symbol = real_client.class.to_s.split('::').shift(2).push('Errors', 'RequestLimitExceeded').join('::').to_sym
15
+ end
16
+
17
+ protected
18
+
19
+ # used to capture only the "RequestLimitExceeded" error from an aws
20
+ # client api call. In the case of matching it we want to try again,
21
+ # backing off successively each time, until the backoff_limit is reached or
22
+ # exceeded, in which case, the error will be re-raised and it should fail
23
+ # as expected.
24
+ def method_missing(m, *args, &block)
25
+ begin
26
+ results = client.send(m, *args, &block)
27
+ rescue Exception => e
28
+ raise unless e.class.to_s == symbol.to_s && backoff < backoff_limit
29
+
30
+ @backoff = backoff + (iteration * iteration * 0.5)
31
+ @iteration += 1
32
+ sleep backoff
33
+ results = self.send(m, *args, &block)
34
+ end
35
+
36
+ reset_backoff
37
+
38
+ results
39
+ end
40
+
41
+ def reset_backoff
42
+ @backoff = @orig_backoff
43
+ @iteration = @orig_iter
44
+ end
45
+ end
46
+ end
@@ -35,6 +35,8 @@ require 'awspec/helper/finder/cloudformation'
35
35
 
36
36
  require 'awspec/helper/finder/account_attributes'
37
37
 
38
+ require 'awspec/helper/client_wrap'
39
+
38
40
  module Awspec::Helper
39
41
  module Finder
40
42
  include Awspec::Helper::Finder::Alb
@@ -111,7 +113,10 @@ module Awspec::Helper
111
113
  CLIENTS.each do |method_name, client|
112
114
  define_method method_name do
113
115
  unless self.methods.include? "@#{method_name}"
114
- instance_variable_set("@#{method_name}", client.new(CLIENT_OPTIONS))
116
+ instance_variable_set(
117
+ "@#{method_name}",
118
+ Awspec::Helper::ClientWrap.new(client.new(CLIENT_OPTIONS))
119
+ )
115
120
  end
116
121
  end
117
122
  end
@@ -50,7 +50,7 @@ module Awspec::Helper
50
50
  method_name = 'describe_' + type + '_filters'
51
51
  resources = []
52
52
  loop do
53
- res = cloudwatch_logs_client.method(method_name).call(req)
53
+ res = cloudwatch_logs_client.send(method_name, req)
54
54
  case type
55
55
  when 'metric' then
56
56
  resources.push(*res.metric_filters)
@@ -41,14 +41,16 @@ module Awspec::Helper
41
41
  define_method 'find_' + type + '_gateway' do |*args|
42
42
  gateway_id = args.first
43
43
  method_name = 'describe_' + type + '_gateways'
44
- res = ec2_client.method(method_name).call({
45
- filters: [{ name: type + '-gateway-id', values: [gateway_id] }]
46
- })
44
+ res = ec2_client.send(
45
+ method_name,
46
+ { filters: [{ name: type + '-gateway-id', values: [gateway_id] }] }
47
+ )
47
48
  resource = res[type + '_gateways'].single_resource(gateway_id)
48
49
  return resource if resource
49
- res = ec2_client.method(method_name).call({
50
- filters: [{ name: 'tag:Name', values: [gateway_id] }]
51
- })
50
+ res = ec2_client.send(
51
+ method_name,
52
+ { filters: [{ name: 'tag:Name', values: [gateway_id] }] }
53
+ )
52
54
  res[type + '_gateways'].single_resource(gateway_id)
53
55
  end
54
56
  end
@@ -7,7 +7,7 @@ module Awspec::Helper
7
7
  define_method 'find_iam_' + type do |*args|
8
8
  id = args.first
9
9
  selected = []
10
- res = iam_client.method('list_' + type.pluralize).call
10
+ res = iam_client.send('list_' + type.pluralize)
11
11
  loop do
12
12
  selected += res[type.pluralize].select do |u|
13
13
  u[type + '_name'] == id || u[type + '_id'] == id || u.arn == id
@@ -40,16 +40,18 @@ module Awspec::Helper
40
40
 
41
41
  %w(user group role).each do |type|
42
42
  define_method 'select_iam_policy_by_' + type + '_name' do |name|
43
- res = iam_client.method('list_attached_' + type + '_policies').call({
44
- (type + '_name').to_sym => name
45
- })
43
+ res = iam_client.send(
44
+ 'list_attached_' + type + '_policies',
45
+ { (type + '_name').to_sym => name }
46
+ )
46
47
  res.attached_policies
47
48
  end
48
49
 
49
50
  define_method 'select_inline_policy_by_' + type + '_name' do |name|
50
- res = iam_client.method('list_' + type + '_policies').call({
51
- (type + '_name').to_sym => name
52
- })
51
+ res = iam_client.send(
52
+ 'list_' + type + '_policies',
53
+ { (type + '_name').to_sym => name }
54
+ )
53
55
  res.policy_names
54
56
  end
55
57
  end
@@ -103,6 +103,7 @@ module Awspec::Type
103
103
  end
104
104
  next true if sg.group_id == cidr
105
105
  sg2 = find_security_group(sg.group_id)
106
+ next false if sg2.nil?
106
107
  next true if sg2.group_name == cidr
107
108
  sg2.tags.find do |tag|
108
109
  tag.key == 'Name' && tag.value == cidr
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.85.3'
2
+ VERSION = '0.85.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmonson_2ndwatch_awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.85.3
4
+ version: 0.85.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-19 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -368,6 +368,7 @@ files:
368
368
  - lib/awspec/generator/spec/vpc.rb
369
369
  - lib/awspec/generator/template.rb
370
370
  - lib/awspec/helper.rb
371
+ - lib/awspec/helper/client_wrap.rb
371
372
  - lib/awspec/helper/color.rb
372
373
  - lib/awspec/helper/finder.rb
373
374
  - lib/awspec/helper/finder/account_attributes.rb