chef-provisioning-aws 3.0.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -5
  3. data/Rakefile +15 -6
  4. data/chef-provisioning-aws.gemspec +17 -17
  5. data/lib/chef/provider/aws_auto_scaling_group.rb +5 -6
  6. data/lib/chef/provider/aws_cache_cluster.rb +21 -15
  7. data/lib/chef/provider/aws_cache_replication_group.rb +12 -8
  8. data/lib/chef/provider/aws_cache_subnet_group.rb +3 -3
  9. data/lib/chef/provider/aws_cloudsearch_domain.rb +9 -13
  10. data/lib/chef/provider/aws_cloudwatch_alarm.rb +10 -12
  11. data/lib/chef/provider/aws_dhcp_options.rb +18 -21
  12. data/lib/chef/provider/aws_ebs_volume.rb +24 -26
  13. data/lib/chef/provider/aws_eip_address.rb +10 -13
  14. data/lib/chef/provider/aws_elasticsearch_domain.rb +19 -18
  15. data/lib/chef/provider/aws_iam_instance_profile.rb +5 -7
  16. data/lib/chef/provider/aws_iam_role.rb +14 -17
  17. data/lib/chef/provider/aws_image.rb +6 -6
  18. data/lib/chef/provider/aws_instance.rb +5 -5
  19. data/lib/chef/provider/aws_internet_gateway.rb +8 -11
  20. data/lib/chef/provider/aws_key_pair.rb +15 -17
  21. data/lib/chef/provider/aws_launch_configuration.rb +11 -14
  22. data/lib/chef/provider/aws_load_balancer.rb +1 -2
  23. data/lib/chef/provider/aws_nat_gateway.rb +6 -7
  24. data/lib/chef/provider/aws_network_acl.rb +28 -29
  25. data/lib/chef/provider/aws_network_interface.rb +25 -27
  26. data/lib/chef/provider/aws_rds_instance.rb +12 -13
  27. data/lib/chef/provider/aws_rds_parameter_group.rb +8 -8
  28. data/lib/chef/provider/aws_rds_subnet_group.rb +8 -9
  29. data/lib/chef/provider/aws_route_table.rb +19 -20
  30. data/lib/chef/provider/aws_s3_bucket.rb +22 -25
  31. data/lib/chef/provider/aws_security_group.rb +268 -285
  32. data/lib/chef/provider/aws_server_certificate.rb +6 -5
  33. data/lib/chef/provider/aws_sns_topic.rb +4 -6
  34. data/lib/chef/provider/aws_sqs_queue.rb +3 -4
  35. data/lib/chef/provider/aws_subnet.rb +29 -34
  36. data/lib/chef/provider/aws_vpc.rb +108 -116
  37. data/lib/chef/provider/aws_vpc_peering_connection.rb +11 -11
  38. data/lib/chef/provisioning/aws_driver.rb +4 -2
  39. data/lib/chef/provisioning/aws_driver/aws_provider.rb +234 -241
  40. data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +5 -7
  41. data/lib/chef/provisioning/aws_driver/aws_resource.rb +182 -185
  42. data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +17 -17
  43. data/lib/chef/provisioning/aws_driver/aws_taggable.rb +13 -15
  44. data/lib/chef/provisioning/aws_driver/aws_tagger.rb +47 -48
  45. data/lib/chef/provisioning/aws_driver/credentials.rb +96 -100
  46. data/lib/chef/provisioning/aws_driver/credentials2.rb +42 -45
  47. data/lib/chef/provisioning/aws_driver/driver.rb +1349 -1362
  48. data/lib/chef/provisioning/aws_driver/exceptions.rb +10 -12
  49. data/lib/chef/provisioning/aws_driver/super_lwrp.rb +60 -60
  50. data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +49 -50
  51. data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +37 -38
  52. data/lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb +14 -15
  53. data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +29 -31
  54. data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +39 -40
  55. data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -43
  56. data/lib/chef/provisioning/aws_driver/version.rb +5 -5
  57. data/lib/chef/provisioning/driver_init/aws.rb +2 -2
  58. data/lib/chef/resource/aws_auto_scaling_group.rb +1 -1
  59. data/lib/chef/resource/aws_cache_cluster.rb +9 -12
  60. data/lib/chef/resource/aws_cache_replication_group.rb +9 -11
  61. data/lib/chef/resource/aws_cache_subnet_group.rb +8 -10
  62. data/lib/chef/resource/aws_cloudsearch_domain.rb +4 -5
  63. data/lib/chef/resource/aws_cloudwatch_alarm.rb +17 -18
  64. data/lib/chef/resource/aws_dhcp_options.rb +2 -2
  65. data/lib/chef/resource/aws_ebs_volume.rb +10 -10
  66. data/lib/chef/resource/aws_eip_address.rb +5 -5
  67. data/lib/chef/resource/aws_elasticsearch_domain.rb +4 -4
  68. data/lib/chef/resource/aws_iam_instance_profile.rb +4 -5
  69. data/lib/chef/resource/aws_iam_role.rb +2 -3
  70. data/lib/chef/resource/aws_image.rb +3 -3
  71. data/lib/chef/resource/aws_instance.rb +4 -4
  72. data/lib/chef/resource/aws_internet_gateway.rb +3 -3
  73. data/lib/chef/resource/aws_key_pair.rb +7 -7
  74. data/lib/chef/resource/aws_launch_configuration.rb +4 -4
  75. data/lib/chef/resource/aws_load_balancer.rb +7 -7
  76. data/lib/chef/resource/aws_nat_gateway.rb +11 -11
  77. data/lib/chef/resource/aws_network_acl.rb +7 -8
  78. data/lib/chef/resource/aws_network_interface.rb +9 -9
  79. data/lib/chef/resource/aws_rds_instance.rb +4 -4
  80. data/lib/chef/resource/aws_rds_parameter_group.rb +3 -3
  81. data/lib/chef/resource/aws_rds_subnet_group.rb +4 -4
  82. data/lib/chef/resource/aws_route53_hosted_zone.rb +37 -40
  83. data/lib/chef/resource/aws_route53_record_set.rb +22 -24
  84. data/lib/chef/resource/aws_route_table.rb +7 -7
  85. data/lib/chef/resource/aws_s3_bucket.rb +7 -7
  86. data/lib/chef/resource/aws_security_group.rb +10 -10
  87. data/lib/chef/resource/aws_server_certificate.rb +6 -8
  88. data/lib/chef/resource/aws_sns_topic.rb +2 -2
  89. data/lib/chef/resource/aws_sqs_queue.rb +5 -7
  90. data/lib/chef/resource/aws_subnet.rb +9 -9
  91. data/lib/chef/resource/aws_vpc.rb +11 -11
  92. data/lib/chef/resource/aws_vpc_peering_connection.rb +4 -4
  93. data/spec/aws_support.rb +44 -45
  94. data/spec/aws_support/aws_resource_run_wrapper.rb +2 -2
  95. data/spec/aws_support/deep_matcher.rb +2 -3
  96. data/spec/aws_support/deep_matcher/fuzzy_match_objects.rb +6 -9
  97. data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +30 -37
  98. data/spec/aws_support/deep_matcher/matchable_array.rb +0 -1
  99. data/spec/aws_support/deep_matcher/matchable_object.rb +1 -2
  100. data/spec/aws_support/deep_matcher/rspec_monkeypatches.rb +4 -4
  101. data/spec/aws_support/delayed_stream.rb +2 -2
  102. data/spec/aws_support/matchers/create_an_aws_object.rb +6 -6
  103. data/spec/aws_support/matchers/destroy_an_aws_object.rb +6 -6
  104. data/spec/aws_support/matchers/have_aws_object_tags.rb +4 -5
  105. data/spec/aws_support/matchers/match_an_aws_object.rb +5 -6
  106. data/spec/aws_support/matchers/update_an_aws_object.rb +6 -7
  107. data/spec/integration/aws_auto_scaling_group_spec.rb +56 -64
  108. data/spec/integration/aws_cache_cluster_spec.rb +70 -71
  109. data/spec/integration/aws_cache_subnet_group_spec.rb +13 -14
  110. data/spec/integration/aws_cloudsearch_domain_spec.rb +6 -8
  111. data/spec/integration/aws_cloudwatch_alarm_spec.rb +200 -208
  112. data/spec/integration/aws_dhcp_options_spec.rb +32 -43
  113. data/spec/integration/aws_ebs_volume_spec.rb +52 -73
  114. data/spec/integration/aws_eip_address_spec.rb +24 -31
  115. data/spec/integration/aws_elasticsearch_domain_spec.rb +31 -33
  116. data/spec/integration/aws_iam_instance_profile_spec.rb +36 -45
  117. data/spec/integration/aws_iam_role_spec.rb +39 -46
  118. data/spec/integration/aws_internet_gateway_spec.rb +64 -75
  119. data/spec/integration/aws_key_pair_spec.rb +6 -6
  120. data/spec/integration/aws_launch_configuration_spec.rb +17 -18
  121. data/spec/integration/aws_nat_gateway_spec.rb +21 -24
  122. data/spec/integration/aws_network_acl_spec.rb +81 -95
  123. data/spec/integration/aws_network_interface_spec.rb +28 -43
  124. data/spec/integration/aws_rds_instance_spec.rb +29 -40
  125. data/spec/integration/aws_rds_parameter_group_spec.rb +32 -35
  126. data/spec/integration/aws_rds_subnet_group_spec.rb +30 -40
  127. data/spec/integration/aws_route53_hosted_zone_spec.rb +205 -205
  128. data/spec/integration/aws_route_table_spec.rb +118 -136
  129. data/spec/integration/aws_s3_bucket_spec.rb +19 -27
  130. data/spec/integration/aws_security_group_spec.rb +369 -388
  131. data/spec/integration/aws_server_certificate_spec.rb +16 -18
  132. data/spec/integration/aws_subnet_spec.rb +44 -58
  133. data/spec/integration/aws_vpc_peering_connection_spec.rb +43 -50
  134. data/spec/integration/aws_vpc_spec.rb +99 -115
  135. data/spec/integration/load_balancer_spec.rb +169 -183
  136. data/spec/integration/machine_batch_spec.rb +24 -31
  137. data/spec/integration/machine_image_spec.rb +54 -66
  138. data/spec/integration/machine_spec.rb +216 -237
  139. data/spec/persistence_file.txt +219 -0
  140. data/spec/spec_helper.rb +16 -17
  141. data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +67 -74
  142. data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +29 -29
  143. data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +13 -15
  144. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52266dc010958b6e3dab75f246cc0938958a36354134532db7edd5a6faa46410
4
- data.tar.gz: 26e30d909b1abf07bebf4aabbed65e0360096d6cbe7810cbd3621ff177a09ff4
3
+ metadata.gz: 39194e58ff45996306d839158acfbb6d958ad733e8547189f86034d13f5efc70
4
+ data.tar.gz: f08035db151ea0fc87f9ae2644db78118b0882f0f98e9e0ef4aa244061e3e8ce
5
5
  SHA512:
6
- metadata.gz: aa7f78ca5df5bfffc74cf5e61bf796f91e8349e3909926e2437af70fad01cf6d693fa083ddbc0ff33aeafd271df851986add1be6b9a32ee94c0554e0505a1f23
7
- data.tar.gz: 4ab0fd175ec409e06787b1a04adaa6939a635fee8ec4e9b36ac9841638efc3eb2de273686b0b232a936316fd4679b68ea840d997d394cb4c3489a63709203367
6
+ metadata.gz: 12d794dfcda191a1dfd2763ce541e5de657388174dd37e375c8678a68b1cdf9189cfbc4607e1aea0c972d7b46261dd68beb8c0c6faf14b994b9bc32b13691bb7
7
+ data.tar.gz: 77033fad69ff95d2c6da77c96a130e3d918223848a8abf9bf31cbbbebf32d56917293646bb71035ed6156bd723ece6ea4b9829778eaa6bfc6c69bb89367047c8
data/Gemfile CHANGED
@@ -1,13 +1,24 @@
1
1
  source "https://rubygems.org"
2
+
2
3
  gemspec
3
4
 
4
5
  gem "chef"
5
- gem 'rb-readline'
6
+ gem "rb-readline"
6
7
 
7
8
  gem "chef-zero", ">= 4.0"
8
- gem "rspec", "~> 3.0"
9
+ gem "chefstyle", "~> 0.10.0"
9
10
  gem "rake"
10
- gem "pry"
11
- gem "pry-byebug"
12
- gem "pry-stack_explorer"
11
+ gem "rspec", "~> 3.0"
13
12
  gem "simplecov"
13
+
14
+ group :debug do
15
+ gem "pry"
16
+ gem "pry-byebug"
17
+ gem "pry-stack_explorer"
18
+ end
19
+
20
+ instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
21
+
22
+ # If you want to load debugging tools into the bundle exec sandbox,
23
+ # add these additional dependencies into Gemfile.local
24
+ eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
data/Rakefile CHANGED
@@ -1,13 +1,12 @@
1
- require "bundler"
2
1
  require "bundler/gem_tasks"
3
2
  require "rspec/core/rake_task"
4
3
 
5
- task :default => :spec
4
+ task default: :spec
6
5
 
7
6
  desc "run all non-integration specs"
8
7
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
8
  spec.pattern = "spec/**/*_spec.rb"
10
- # TODO add back integration tests whenever we have strategy for keys
9
+ # TODO: add back integration tests whenever we have strategy for keys
11
10
  spec.exclude_pattern = "spec/integration/**/*_spec.rb"
12
11
  end
13
12
 
@@ -30,17 +29,17 @@ end
30
29
 
31
30
  desc "run all specs, including :super_slow"
32
31
  task :all_slow do
33
- %w(all slow).each do |t|
32
+ %w{all slow}.each do |t|
34
33
  Rake::Task[t].invoke
35
34
  end
36
35
  end
37
36
 
38
37
  desc "travis specific task - runs CI integration tests (regular and super_slow in parallel) and sets up travis specific ENV variables"
39
- task :travis, [:sub_task] do |t, args|
38
+ task :travis, [:sub_task] do |_t, args|
40
39
  sub_task = args[:sub_task]
41
40
  if sub_task == "super_slow"
42
41
  pattern = "load_balancer_spec.rb,aws_route_table_spec.rb,machine_spec.rb,aws_eip_address_spec.rb" # This is a comma seperated list
43
- pattern = pattern.split(",").map {|p| "spec/integration/**/*#{p}"}.join(",")
42
+ pattern = pattern.split(",").map { |p| "spec/integration/**/*#{p}" }.join(",")
44
43
  else
45
44
  pattern = "spec/integration/**/*_spec.rb"
46
45
  end
@@ -52,3 +51,13 @@ RSpec::Core::RakeTask.new(:machine_image) do |spec|
52
51
  spec.pattern = "spec/integration/machine_image_spec.rb"
53
52
  spec.rspec_opts = "-b -t super_slow -e 'machine_image can create an image in the VPC'"
54
53
  end
54
+
55
+ begin
56
+ require "chefstyle"
57
+ require "rubocop/rake_task"
58
+ RuboCop::RakeTask.new(:chefstyle) do |task|
59
+ task.options << "--display-cop-names"
60
+ end
61
+ rescue LoadError
62
+ puts "chefstyle gem is not installed"
63
+ end
@@ -1,30 +1,30 @@
1
- $:.unshift(File.dirname(__FILE__) + '/lib')
2
- require 'chef/provisioning/aws_driver/version'
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/lib")
2
+ require "chef/provisioning/aws_driver/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = 'chef-provisioning-aws'
5
+ s.name = "chef-provisioning-aws"
6
6
  s.version = Chef::Provisioning::AWSDriver::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.extra_rdoc_files = ['README.md', 'LICENSE' ]
9
- s.summary = 'Provisioner for creating aws containers in Chef Provisioning.'
8
+ s.extra_rdoc_files = ["README.md", "LICENSE"]
9
+ s.summary = "Provisioner for creating aws containers in Chef Provisioning."
10
10
  s.description = s.summary
11
- s.author = 'Tyler Ball'
12
- s.email = 'tball@chef.io'
13
- s.homepage = 'https://github.com/chef/chef-provisioning-aws'
14
- s.license = 'Apache-2.0'
11
+ s.author = "Tyler Ball"
12
+ s.email = "tball@chef.io"
13
+ s.homepage = "https://github.com/chef/chef-provisioning-aws"
14
+ s.license = "Apache-2.0"
15
15
 
16
16
  s.required_ruby_version = ">= 2.1.9"
17
17
 
18
- s.add_dependency 'chef-provisioning', '>= 1.0', '< 3.0'
18
+ s.add_dependency "chef-provisioning", ">= 1.0", "< 3.0"
19
19
 
20
- s.add_dependency 'aws-sdk', ['>= 2.2.18', '< 3.0']
21
- s.add_dependency 'retryable', '~> 2.0', '>= 2.0.1'
22
- s.add_dependency 'ubuntu_ami', '~> 0.4', '>= 0.4.1'
20
+ s.add_dependency "aws-sdk", [">= 2.2.18", "< 3.0"]
21
+ s.add_dependency "retryable", "~> 2.0", ">= 2.0.1"
22
+ s.add_dependency "ubuntu_ami", "~> 0.4", ">= 0.4.1"
23
23
 
24
24
  s.bindir = "bin"
25
- s.executables = %w( )
25
+ s.executables = %w{}
26
26
 
27
- s.require_path = 'lib'
28
- s.files = %w(Gemfile Rakefile LICENSE README.md) + Dir.glob("*.gemspec") +
29
- Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
27
+ s.require_path = "lib"
28
+ s.files = %w{Gemfile Rakefile LICENSE README.md} + Dir.glob("*.gemspec") +
29
+ Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
30
30
  end
@@ -1,6 +1,6 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
2
- require 'set'
3
- require 'chef/provisioning/aws_driver/tagging_strategy/auto_scaling'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
+ require "set"
3
+ require "chef/provisioning/aws_driver/tagging_strategy/auto_scaling"
4
4
 
5
5
  class Chef::Provider::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSProvider
6
6
  include Chef::Provisioning::AWSDriver::TaggingStrategy::AutoScalingConvergeTags
@@ -34,7 +34,7 @@ class Chef::Provider::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSPr
34
34
  end
35
35
 
36
36
  def update_aws_object(group)
37
- # TODO add updates for group
37
+ # TODO: add updates for group
38
38
  end
39
39
 
40
40
  def destroy_aws_object(group)
@@ -47,7 +47,7 @@ class Chef::Provider::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSPr
47
47
  def desired_options
48
48
  @desired_options ||= begin
49
49
  options = new_resource.options.dup
50
- %w( min_size max_size availability_zones desired_capacity ).each do |var|
50
+ %w{min_size max_size availability_zones desired_capacity}.each do |var|
51
51
  var = var.to_sym
52
52
  value = new_resource.public_send(var)
53
53
  options[var] = value if value
@@ -55,5 +55,4 @@ class Chef::Provider::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSPr
55
55
  AWSResource.lookup_options(options, resource: new_resource)
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -1,5 +1,5 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
2
- require 'retryable'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
+ require "retryable"
3
3
 
4
4
  class Chef::Provider::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSProvider
5
5
  provides :aws_cache_cluster
@@ -54,20 +54,26 @@ class Chef::Provider::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSProvid
54
54
  options[:cache_node_type] = new_resource.node_type
55
55
  options[:engine] = new_resource.engine
56
56
  options[:az_mode] = new_resource.az_mode if new_resource.az_mode
57
- options[:preferred_availability_zone] =
58
- new_resource.preferred_availability_zone if new_resource.preferred_availability_zone
59
- options[:preferred_availability_zones] =
60
- new_resource.preferred_availability_zones if new_resource.preferred_availability_zones
57
+ if new_resource.preferred_availability_zone
58
+ options[:preferred_availability_zone] =
59
+ new_resource.preferred_availability_zone
60
+ end
61
+ if new_resource.preferred_availability_zones
62
+ options[:preferred_availability_zones] =
63
+ new_resource.preferred_availability_zones
64
+ end
61
65
  options[:engine_version] = new_resource.engine_version
62
- options[:cache_subnet_group_name] =
63
- new_resource.subnet_group_name if new_resource.subnet_group_name
66
+ if new_resource.subnet_group_name
67
+ options[:cache_subnet_group_name] =
68
+ new_resource.subnet_group_name
69
+ end
64
70
  options[:security_group_ids] = new_resource.security_groups
65
71
  AWSResource.lookup_options(options, resource: new_resource)
66
72
  end
67
73
  end
68
74
 
69
75
  def updatable_options(options)
70
- updatable = [:security_groups, :num_cache_nodes, :engine_version]
76
+ updatable = %i{security_groups num_cache_nodes engine_version}
71
77
  options.delete_if { |option, _value| !updatable.include?(option) }
72
78
  end
73
79
 
@@ -75,21 +81,21 @@ class Chef::Provider::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSProvid
75
81
  current_sg_ids = cache_cluster[:security_groups].map { |sg| sg[:security_group_id] }.sort
76
82
 
77
83
  if desired_options[:security_group_ids].sort != current_sg_ids ||
78
- desired_options[:num_cache_nodes] != cache_cluster[:num_cache_nodes] ||
79
- desired_options[:engine_version] != cache_cluster[:engine_version]
84
+ desired_options[:num_cache_nodes] != cache_cluster[:num_cache_nodes] ||
85
+ desired_options[:engine_version] != cache_cluster[:engine_version]
80
86
  true
81
87
  else
82
88
  false
83
89
  end
84
90
  end
85
91
 
86
- def wait_for_cache_cluster_state(aws_object, expected_status, tries=60, sleep=5)
92
+ def wait_for_cache_cluster_state(aws_object, expected_status, tries = 60, sleep = 5)
87
93
  query_method = :cache_cluster_status
88
94
 
89
- Retryable.retryable(:tries => tries, :sleep => sleep) do |retries, exception|
90
- action_handler.report_progress "waited #{retries*sleep}/#{tries*sleep}s for <#{aws_object.class}:#{aws_object.cache_cluster_id}>##{query_method} state to change to #{expected_status}..."
95
+ Retryable.retryable(tries: tries, sleep: sleep) do |retries, exception|
96
+ action_handler.report_progress "waited #{retries * sleep}/#{tries * sleep}s for <#{aws_object.class}:#{aws_object.cache_cluster_id}>##{query_method} state to change to #{expected_status}..."
91
97
  Chef::Log.debug("Current exception in wait_for is #{exception.inspect}") if exception
92
- cache_cluster = new_resource.driver.elasticache.describe_cache_clusters(cache_cluster_id: aws_object.cache_cluster_id)
98
+ cache_cluster = new_resource.driver.elasticache.describe_cache_clusters(cache_cluster_id: aws_object.cache_cluster_id)
93
99
  status = cache_cluster.cache_clusters.first.cache_cluster_status
94
100
  action_handler.report_progress "Current Cluster Status: #{status}"
95
101
  raise CacheClusterStatusTimeoutError.new(aws_object, status, expected_status) if status != expected_status.to_s
@@ -1,8 +1,8 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
2
 
3
3
  class Chef::Provider::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  provides :aws_cache_replication_group
5
-
5
+
6
6
  protected
7
7
 
8
8
  def create_aws_object
@@ -11,8 +11,8 @@ class Chef::Provider::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
11
11
  end
12
12
  end
13
13
 
14
- def update_aws_object(cache_replication_group)
15
- Chef::Log.warn('Updating ElastiCache replication groups is currently unsupported')
14
+ def update_aws_object(_cache_replication_group)
15
+ Chef::Log.warn("Updating ElastiCache replication groups is currently unsupported")
16
16
  end
17
17
 
18
18
  def destroy_aws_object(cache_replication_group)
@@ -39,10 +39,14 @@ class Chef::Provider::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
39
39
  options[:cache_node_type] = new_resource.node_type
40
40
  options[:engine] = new_resource.engine
41
41
  options[:engine_version] = new_resource.engine_version
42
- options[:preferred_cache_cluster_a_zs] =
43
- new_resource.preferred_availability_zones if new_resource.preferred_availability_zones
44
- options[:cache_subnet_group_name] =
45
- new_resource.subnet_group_name if new_resource.subnet_group_name
42
+ if new_resource.preferred_availability_zones
43
+ options[:preferred_cache_cluster_a_zs] =
44
+ new_resource.preferred_availability_zones
45
+ end
46
+ if new_resource.subnet_group_name
47
+ options[:cache_subnet_group_name] =
48
+ new_resource.subnet_group_name
49
+ end
46
50
  options[:security_group_ids] = new_resource.security_groups
47
51
  AWSResource.lookup_options(options, resource: new_resource)
48
52
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
2
 
3
3
  class Chef::Provider::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  provides :aws_cache_subnet_group
@@ -49,10 +49,10 @@ class Chef::Provider::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSPr
49
49
 
50
50
  def update_required?(cache_subnet_group)
51
51
  current_subnet_ids = cache_subnet_group[:subnets]
52
- .map { |subnet| subnet[:subnet_identifier] }.sort
52
+ .map { |subnet| subnet[:subnet_identifier] }.sort
53
53
  current_description = cache_subnet_group[:cache_subnet_group_description]
54
54
  if new_resource.description != current_description ||
55
- desired_options[:subnet_ids].sort != current_subnet_ids
55
+ desired_options[:subnet_ids].sort != current_subnet_ids
56
56
  true
57
57
  else
58
58
  false
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
2
 
3
3
  class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  provides :aws_cloudsearch_domain
@@ -17,7 +17,7 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
17
17
  create_index_fields
18
18
  end
19
19
 
20
- def destroy_aws_object(domain)
20
+ def destroy_aws_object(_domain)
21
21
  converge_by "delete CloudSearch domain #{new_resource.name}" do
22
22
  cs_client.delete_domain(domain_name: new_resource.name)
23
23
  end
@@ -79,10 +79,10 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
79
79
  end
80
80
  end
81
81
 
82
- def update_index_fields?(domain)
83
- if ! new_resource.index_fields.nil?
82
+ def update_index_fields?(_domain)
83
+ if !new_resource.index_fields.nil?
84
84
  index_fields.each do |index_field|
85
- if ! new_resource.index_fields.include?(index_field.to_h[:options])
85
+ unless new_resource.index_fields.include?(index_field.to_h[:options])
86
86
  return true
87
87
  end
88
88
  end
@@ -96,7 +96,7 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
96
96
  ret = {}
97
97
  ret[:desired_partition_count] = new_resource.partition_count if new_resource.partition_count
98
98
  ret[:desired_replication_count] = new_resource.replication_count if new_resource.replication_count
99
- ret[:desired_instance_type] = new_resource.instance_type if new_resource.instance_type
99
+ ret[:desired_instance_type] = new_resource.instance_type if new_resource.instance_type
100
100
  ret
101
101
  end
102
102
 
@@ -166,14 +166,10 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
166
166
  cs_client.describe_index_fields(domain_name: new_resource.name).index_fields
167
167
  end
168
168
 
169
- def get_option(option_name, key=nil)
169
+ def get_option(option_name, key = nil)
170
170
  opt = cs_client.send("describe_#{option_name}".to_sym,
171
- {domain_name: new_resource.name})[key || option_name]
172
- if ! opt[:status][:pending_deletion]
173
- opt[:options]
174
- else
175
- nil
176
- end
171
+ domain_name: new_resource.name)[key || option_name]
172
+ opt[:options] unless opt[:status][:pending_deletion]
177
173
  end
178
174
 
179
175
  def cs_client
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
2
 
3
3
  class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  provides :aws_cloudwatch_alarm
@@ -28,10 +28,10 @@ class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSPro
28
28
  # Because an update is a PUT, we must ensure that any properties not specified
29
29
  # on the resource that are already present on the object stay the same
30
30
  aws_object = new_resource.aws_object
31
- opts = {alarm_name: new_resource.name}
32
- %i(namespace metric_name comparison_operator
31
+ opts = { alarm_name: new_resource.name }
32
+ %i{namespace metric_name comparison_operator
33
33
  evaluation_periods period statistic threshold
34
- actions_enabled alarm_description unit).each do |opt|
34
+ actions_enabled alarm_description unit}.each do |opt|
35
35
  if !new_resource.public_send(opt).nil?
36
36
  opts[opt] = new_resource.public_send(opt)
37
37
  elsif aws_object && !aws_object.public_send(opt).nil?
@@ -41,7 +41,7 @@ class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSPro
41
41
  if !new_resource.dimensions.nil?
42
42
  opts[:dimensions] = new_resource.dimensions
43
43
  elsif aws_object && !aws_object.dimensions.nil?
44
- opts[:dimensions] = aws_object.dimensions.map! {|d| d.to_h}
44
+ opts[:dimensions] = aws_object.dimensions.map!(&:to_h)
45
45
  end
46
46
  # Normally we would just use `lookup_options` here but because these parameters
47
47
  # don't necessarily sound like sns topics we manually do it
@@ -49,7 +49,7 @@ class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSPro
49
49
  if !new_resource.public_send(opt).nil?
50
50
  opts[opt] = new_resource.public_send(opt)
51
51
  opts[opt].map! do |action|
52
- if action.kind_of?(String) && !(action =~ /^arn:/)
52
+ if action.is_a?(String) && action !~ /^arn:/
53
53
  aws_object = Chef::Resource::AwsSnsTopic.get_aws_object(action, resource: new_resource)
54
54
  action = aws_object.attributes["TopicArn"] if aws_object
55
55
  end
@@ -67,18 +67,16 @@ class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSPro
67
67
  %i{namespace metric_name comparison_operator
68
68
  evaluation_periods period statistic threshold
69
69
  actions_enabled alarm_description unit}.each do |opt|
70
- if alarm.public_send(opt) != desired_options[opt]
71
- return true
72
- end
70
+ return true if alarm.public_send(opt) != desired_options[opt]
73
71
  end
74
- unless (Set.new(alarm.dimensions.map {|d| d.to_h}) ^ Set.new(desired_options[:dimensions])).empty?
72
+ unless (Set.new(alarm.dimensions.map(&:to_h)) ^ Set.new(desired_options[:dimensions])).empty?
75
73
  return true
76
74
  end
77
- %i(insufficient_data_actions ok_actions alarm_actions).each do |opt|
75
+ %i{insufficient_data_actions ok_actions alarm_actions}.each do |opt|
78
76
  unless (Set.new(alarm.public_send(opt)) ^ Set.new(desired_options[opt])).empty?
79
77
  return true
80
78
  end
81
79
  end
82
- return false
80
+ false
83
81
  end
84
82
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_provider'
1
+ require "chef/provisioning/aws_driver/aws_provider"
2
2
 
3
3
  class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  include Chef::Provisioning::AWSDriver::TaggingStrategy::EC2ConvergeTags
@@ -9,35 +9,33 @@ class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvide
9
9
 
10
10
  def create_aws_object
11
11
  options = desired_options
12
- if options.empty?
13
- options[:domain_name_servers] = "AmazonProvidedDNS"
14
- end
12
+ options[:domain_name_servers] = "AmazonProvidedDNS" if options.empty?
15
13
 
16
14
  converge_by "create DHCP options #{new_resource.name} in #{region}" do
17
15
  create_dhcp_options options
18
16
  end
19
17
  end
20
18
 
21
- def create_dhcp_options options
22
- options = options.map{|k,v| {key: k.to_s.gsub('_', '-'), values: Array(v).map(&:to_s)}}
19
+ def create_dhcp_options(options)
20
+ options = options.map { |k, v| { key: k.to_s.tr("_", "-"), values: Array(v).map(&:to_s) } }
23
21
  ec2_resource = ::Aws::EC2::Resource.new(new_resource.driver.ec2)
24
- dhcp_options = ec2_resource.create_dhcp_options({dhcp_configurations: options})
22
+ dhcp_options = ec2_resource.create_dhcp_options(dhcp_configurations: options)
25
23
  retry_with_backoff(::Aws::EC2::Errors::InvalidDhcpOptionIDNotFound) do
26
- dhcp_options.create_tags({tags: [{key: "Name", value: new_resource.name}]})
24
+ dhcp_options.create_tags(tags: [{ key: "Name", value: new_resource.name }])
27
25
  end
28
26
  dhcp_options
29
27
  end
30
28
 
31
29
  def update_aws_object(dhcp_options)
32
30
  # Verify unmodifiable attributes of existing dhcp_options
33
- config = dhcp_options.data.to_h[:dhcp_configurations].map{|a|{a[:key].gsub('-', '_').to_sym => a[:values].map{|k|k[:value]} }}.reduce Hash.new, :merge
34
- differing_options = desired_options.select { |name, value| config[name] != Array(value).map(&:to_s) }
35
- if !differing_options.empty?
31
+ config = dhcp_options.data.to_h[:dhcp_configurations].map { |a| { a[:key].tr("-", "_").to_sym => a[:values].map { |k| k[:value] } } }.reduce({}, :merge)
32
+ differing_options = desired_options.reject { |name, value| config[name] == Array(value).map(&:to_s) }
33
+ unless differing_options.empty?
36
34
  old_dhcp_options = dhcp_options
37
35
  # Report what we are trying to change ...
38
- action_handler.report_progress "update #{new_resource.to_s}"
36
+ action_handler.report_progress "update #{new_resource}"
39
37
  differing_options.each do |name, value|
40
- action_handler.report_progress " set #{name} to #{value.inspect} (was #{config.has_key?(name) ? config[name].inspect : "not set"})"
38
+ action_handler.report_progress " set #{name} to #{value.inspect} (was #{config.key?(name) ? config[name].inspect : 'not set'})"
41
39
  end
42
40
 
43
41
  # create new dhcp_options
@@ -49,12 +47,11 @@ class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvide
49
47
  # attach dhcp_options to existing vpcs
50
48
  ec2_resource = ::Aws::EC2::Resource.new(new_resource.driver.ec2)
51
49
  ec2_resource.vpcs.each do |vpc|
52
- if vpc.dhcp_options_id == old_dhcp_options.id
53
- dhcp_options.associate_with_vpc({
54
- dry_run: false,
55
- vpc_id: vpc.id, # required
56
- })
57
- end
50
+ next unless vpc.dhcp_options_id == old_dhcp_options.id
51
+ dhcp_options.associate_with_vpc(
52
+ dry_run: false,
53
+ vpc_id: vpc.id, # required
54
+ )
58
55
  end
59
56
 
60
57
  # delete old dhcp_options
@@ -62,7 +59,7 @@ class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvide
62
59
  old_dhcp_options.delete
63
60
  end
64
61
 
65
- [ :replaced_aws_object, dhcp_options ]
62
+ [:replaced_aws_object, dhcp_options]
66
63
  end
67
64
  end
68
65
 
@@ -76,7 +73,7 @@ class Chef::Provider::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSProvide
76
73
 
77
74
  def desired_options
78
75
  desired_options = {}
79
- %w(domain_name domain_name_servers ntp_servers netbios_name_servers netbios_node_type).each do |attr|
76
+ %w{domain_name domain_name_servers ntp_servers netbios_name_servers netbios_node_type}.each do |attr|
80
77
  attr = attr.to_sym
81
78
  value = new_resource.public_send(attr)
82
79
  desired_options[attr] = value unless value.nil?