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
@@ -9,10 +9,9 @@ module AWSSupport
9
9
  # end
10
10
  #
11
11
  module FuzzyMatchObjects
12
-
13
- require 'rspec/support/fuzzy_matcher'
14
- require 'aws_support/deep_matcher/matchable_object'
15
- require 'aws_support/deep_matcher/matchable_array'
12
+ require "rspec/support/fuzzy_matcher"
13
+ require "aws_support/deep_matcher/matchable_object"
14
+ require "aws_support/deep_matcher/matchable_array"
16
15
 
17
16
  def values_match?(expected, actual)
18
17
  if Hash === expected
@@ -28,12 +27,10 @@ module AWSSupport
28
27
  expected_hash.all? do |expected_key, expected_value|
29
28
  # 'a.b.c' => 1 -> { 'a' => { 'b' => { 'c' => 1 } } }
30
29
  # :"a.b.c" => 1 -> { :a => { :b => { :c => 1 } } }
31
- names = expected_key.to_s.split('.')
30
+ names = expected_key.to_s.split(".")
32
31
  if names.size > 1
33
32
  expected_key = expected_key.is_a?(Symbol) ? names.shift.to_sym : names.shift
34
- while !names.empty?
35
- expected_value = { names.pop => expected_value }
36
- end
33
+ expected_value = { names.pop => expected_value } until names.empty?
37
34
  end
38
35
 
39
36
  # Grab the actual value from the object
@@ -47,7 +44,7 @@ module AWSSupport
47
44
  end
48
45
  end
49
46
 
50
- return false if !values_match?(expected, actual)
47
+ return false unless values_match?(expected, actual)
51
48
  end
52
49
 
53
50
  true
@@ -1,22 +1,21 @@
1
1
  module AWSSupport
2
2
  module DeepMatcher
3
3
  module MatchValuesFailureMessages
4
-
5
- require 'set'
6
- require 'rspec/matchers'
7
- require 'rspec/matchers/composable'
8
- require 'aws_support/deep_matcher'
9
- require 'aws_support/deep_matcher/matchable_object'
10
- require 'aws_support/deep_matcher/matchable_array'
4
+ require "set"
5
+ require "rspec/matchers"
6
+ require "rspec/matchers/composable"
7
+ require "aws_support/deep_matcher"
8
+ require "aws_support/deep_matcher/matchable_object"
9
+ require "aws_support/deep_matcher/matchable_array"
11
10
 
12
11
  protected
13
12
 
14
- def match_values_failure_messages(expected, actual, identifier=nil)
13
+ def match_values_failure_messages(expected, actual, identifier = nil)
15
14
  if DeepMatcher === expected
16
15
  return expected.match_failure_messages(actual, identifier)
17
16
  elsif RSpec::Matchers::Composable === expected
18
17
  if !expected.matches?(actual)
19
- return [ expected.failure_message ]
18
+ return [expected.failure_message]
20
19
  else
21
20
  return []
22
21
  end
@@ -33,31 +32,29 @@ module AWSSupport
33
32
  if values_match?(expected, actual)
34
33
  []
35
34
  elsif expected.respond_to?(:failure_message)
36
- [ "#{identifier ? "#{identifier}: " : ""}#{expected.failure_message}" ]
35
+ ["#{identifier ? "#{identifier}: " : ''}#{expected.failure_message}"]
37
36
  else
38
- [ "#{identifier ? "#{identifier}: " : ""}expected #{description_of(expected)}, but actual value was #{actual.inspect}" ]
37
+ ["#{identifier ? "#{identifier}: " : ''}expected #{description_of(expected)}, but actual value was #{actual.inspect}"]
39
38
  end
40
39
  end
41
40
 
42
41
  def match_sets_failure_messages(expected_set, actual_setlike, identifier)
43
42
  result = []
44
- if ! actual_setlike.respond_to?(:to_set)
45
- result << "expected #{identifier || "setlike"} to be castable to a Set, but it isn't!"
43
+ if !actual_setlike.respond_to?(:to_set)
44
+ result << "expected #{identifier || 'setlike'} to be castable to a Set, but it isn't!"
46
45
  else
47
46
  actual_set = actual_setlike.to_set
48
47
  expected_set.each do |expected|
49
- unless actual_set.any? { |actual|
48
+ next if actual_set.any? do |actual|
50
49
  match_values_failure_messages(expected, actual, identifier).flatten.empty?
51
- }
52
- result << "- #{description_of(expected)}"
53
50
  end
51
+ result << "- #{description_of(expected)}"
54
52
  end
55
53
  actual_set.each do |actual|
56
- unless expected_set.any? { |expected|
54
+ next if expected_set.any? do |expected|
57
55
  match_values_failure_messages(expected, actual, identifier).flatten.empty?
58
- }
59
- result << "+ #{description_of(actual)}"
60
56
  end
57
+ result << "+ #{description_of(actual)}"
61
58
  end
62
59
  end
63
60
  result
@@ -68,7 +65,7 @@ module AWSSupport
68
65
  expected_hash.all? do |expected_key, expected_value|
69
66
  missing_value = false
70
67
  actual_value = actual_hash.fetch(expected_key) do
71
- result << "expected #{identifier || "hash"}.fetch(#{expected_key.inspect}) to #{description_of(expected_value)}, but it was missing entirely from the hash"
68
+ result << "expected #{identifier || 'hash'}.fetch(#{expected_key.inspect}) to #{description_of(expected_value)}, but it was missing entirely from the hash"
72
69
  missing_value = true
73
70
  end
74
71
  unless missing_value
@@ -84,32 +81,30 @@ module AWSSupport
84
81
  # which.
85
82
  #
86
83
  def match_arrays_failure_messages(expected_list, actual_list, identifier)
87
- result = [ "#{identifier || "value"} is different from expected! Differences:" ]
84
+ result = ["#{identifier || 'value'} is different from expected! Differences:"]
88
85
 
89
86
  different = false
90
87
 
91
88
  expected_list = expected_list.map { |v| ExpectedValue.new(v) }
92
- unless actual_list.class <= Array
93
- actual_list = actual_list.to_a
94
- end
89
+ actual_list = actual_list.to_a unless actual_list.class <= Array
95
90
  Diff::LCS.sdiff(expected_list, actual_list) do |change|
96
91
  case change.action
97
- when '='
98
- messages = [ change.new_element.inspect ]
99
- when '+'
100
- messages = [ change.new_element.inspect ]
92
+ when "="
93
+ messages = [change.new_element.inspect]
94
+ when "+"
95
+ messages = [change.new_element.inspect]
101
96
  different = true
102
- when '-'
103
- messages = [ change.old_element.value.inspect ]
97
+ when "-"
98
+ messages = [change.old_element.value.inspect]
104
99
  different = true
105
- when '!'
100
+ when "!"
106
101
  messages = change.old_element.failure_messages(change.new_element)
107
102
  different = true
108
103
  else
109
104
  raise "Unknown operator returned from sdiff: #{op}"
110
105
  end
111
106
  op = change.action
112
- op = ' ' if op == '='
107
+ op = " " if op == "="
113
108
 
114
109
  result += messages.flat_map { |m| m.split("\n") }.map { |m| "#{op} #{m}" } if messages
115
110
  end
@@ -120,12 +115,10 @@ module AWSSupport
120
115
  result = []
121
116
  expected_hash.all? do |expected_key, expected_value|
122
117
  # 'a.b.c' => 1 -> { a: { b: { c: 1 }}}
123
- names = expected_key.to_s.split('.')
118
+ names = expected_key.to_s.split(".")
124
119
  if names.size > 1
125
120
  expected_key = names.shift
126
- while !names.empty?
127
- expected_value = { names.pop => expected_value }
128
- end
121
+ expected_value = { names.pop => expected_value } until names.empty?
129
122
  end
130
123
 
131
124
  # Grab the actual value from the object
@@ -144,7 +137,7 @@ module AWSSupport
144
137
  end
145
138
  rescue NoMethodError
146
139
  if !actual_value.respond_to?(expected_key)
147
- result << "#{identifier || "object"}.send(#{expected_key.inspect}) is missing, expected value #{description_of(expected_value)}"
140
+ result << "#{identifier || 'object'}.send(#{expected_key.inspect}) is missing, expected value #{description_of(expected_value)}"
148
141
  next
149
142
  else
150
143
  raise
@@ -4,7 +4,6 @@ module AWSSupport
4
4
  # If a module implements this, it signifies that
5
5
  #
6
6
  module MatchableArray
7
-
8
7
  #
9
8
  # TODO allow the user to return a new object that actually implements the
10
9
  # enumerable, in case the class in question is non-standard.
@@ -11,13 +11,12 @@ module AWSSupport
11
11
  # Which will compare my_object.a to 1 and my_object.b to 2.
12
12
  #
13
13
  module MatchableObject
14
-
15
14
  def self.matchable_classes
16
15
  @matchable_classes ||= []
17
16
  end
18
17
 
19
18
  def self.===(other)
20
- return true if matchable_classes.any? { |c| c === other}
19
+ return true if matchable_classes.any? { |c| c === other }
21
20
  super
22
21
  end
23
22
  end
@@ -15,10 +15,10 @@ module RSpec
15
15
  end
16
16
  end
17
17
 
18
- require 'aws_support/deep_matcher/match_values_failure_messages'
19
- require 'rspec/matchers/composable'
20
- require 'rspec/support/fuzzy_matcher'
21
- require 'aws_support/deep_matcher/fuzzy_match_objects'
18
+ require "aws_support/deep_matcher/match_values_failure_messages"
19
+ require "rspec/matchers/composable"
20
+ require "rspec/support/fuzzy_matcher"
21
+ require "aws_support/deep_matcher/fuzzy_match_objects"
22
22
 
23
23
  module RSpec::Support::FuzzyMatcher
24
24
  prepend AWSSupport::DeepMatcher::FuzzyMatchObjects
@@ -1,9 +1,9 @@
1
- require 'timeout'
1
+ require "timeout"
2
2
 
3
3
  module AWSSupport
4
4
  class DelayedStream
5
5
  def initialize(delay_before_streaming, *streams)
6
- @streams = streams.flatten.select { |s| !s.nil? }
6
+ @streams = streams.flatten.reject(&:nil?)
7
7
  if delay_before_streaming > 0
8
8
  @buffer = StringIO.new
9
9
  @thread = Thread.new do
@@ -1,6 +1,6 @@
1
- require 'rspec/matchers'
2
- require 'chef/provisioning'
3
- require 'aws_support/deep_matcher'
1
+ require "rspec/matchers"
2
+ require "chef/provisioning"
3
+ require "aws_support/deep_matcher"
4
4
 
5
5
  module AWSSupport
6
6
  module Matchers
@@ -32,13 +32,13 @@ module AWSSupport
32
32
 
33
33
  # We want to record that it was created BEFORE the converge, so that
34
34
  # even if it fails, we destroy it.
35
- example.created_during_test << [ resource_name, name ]
35
+ example.created_during_test << [resource_name, name]
36
36
 
37
37
  # Converge
38
38
  begin
39
39
  recipe.converge unless recipe.converged?
40
- rescue
41
- differences += [ "error trying to create #{resource_name}[#{name}]!\n#{($!.backtrace.map { |line| "- #{line}\n" } + [ recipe.output_for_failure_message ]).join("")}" ]
40
+ rescue StandardError
41
+ differences += ["error trying to create #{resource_name}[#{name}]!\n#{($ERROR_INFO.backtrace.map { |line| "- #{line}\n" } + [recipe.output_for_failure_message]).join('')}"]
42
42
  end
43
43
 
44
44
  # Check whether the recipe caused an update or not
@@ -1,6 +1,6 @@
1
- require 'rspec/matchers'
2
- require 'chef/provisioning'
3
- require 'aws_support/deep_matcher'
1
+ require "rspec/matchers"
2
+ require "chef/provisioning"
3
+ require "aws_support/deep_matcher"
4
4
 
5
5
  module AWSSupport
6
6
  module Matchers
@@ -31,7 +31,7 @@ module AWSSupport
31
31
  def match_failure_messages(recipe)
32
32
  differences = []
33
33
 
34
- if !had_initial_value
34
+ unless had_initial_value
35
35
  differences << "expected recipe to delete #{resource_name}[#{name}], but the AWS object did not exist before recipe ran!"
36
36
  return differences
37
37
  end
@@ -39,8 +39,8 @@ module AWSSupport
39
39
  # Converge
40
40
  begin
41
41
  recipe.converge unless recipe.converged?
42
- rescue
43
- differences += [ "error trying to delete #{resource_name}[#{name}]!\n#{($!.backtrace.map { |line| "- #{line}\n" } + [ recipe.output_for_failure_message ]).join("")}" ]
42
+ rescue StandardError
43
+ differences += ["error trying to delete #{resource_name}[#{name}]!\n#{($ERROR_INFO.backtrace.map { |line| "- #{line}\n" } + [recipe.output_for_failure_message]).join('')}"]
44
44
  end
45
45
 
46
46
  # Check whether the recipe caused an update or not
@@ -1,6 +1,6 @@
1
- require 'rspec/matchers'
2
- require 'chef/provisioning'
3
- require 'aws_support/deep_matcher'
1
+ require "rspec/matchers"
2
+ require "chef/provisioning"
3
+ require "aws_support/deep_matcher"
4
4
 
5
5
  module AWSSupport
6
6
  module Matchers
@@ -34,7 +34,7 @@ module AWSSupport
34
34
 
35
35
  # Check existence
36
36
  if @aws_object.nil?
37
- differences << "#{resource.to_s} did not exist!"
37
+ differences << "#{resource} did not exist!"
38
38
  else
39
39
  differences += match_hashes_failure_messages(expected_tags, aws_object_tags(resource), resource.to_s)
40
40
  end
@@ -51,7 +51,6 @@ module AWSSupport
51
51
  provider = resource.provider_for_action(:create)
52
52
  provider.aws_tagger.current_tags
53
53
  end
54
-
55
54
  end
56
55
  end
57
56
  end
@@ -1,10 +1,9 @@
1
- require 'rspec/matchers'
2
- require 'chef/provisioning'
3
- require 'aws_support/deep_matcher'
1
+ require "rspec/matchers"
2
+ require "chef/provisioning"
3
+ require "aws_support/deep_matcher"
4
4
 
5
5
  module AWSSupport
6
6
  module Matchers
7
-
8
7
  # This matcher doesn't try to validate that an example was created/updated/destroyed
9
8
  # it just checks that the object exists and posses the attributes you specify
10
9
  # It also doesn't clean up any aws objects so only use if the resource is defined outside
@@ -38,8 +37,8 @@ module AWSSupport
38
37
  # Converge
39
38
  begin
40
39
  recipe.converge unless recipe.converged?
41
- rescue
42
- differences += [ "error trying to converge #{resource_name}[#{name}]!\n#{($!.backtrace.map { |line| "- #{line}\n" } + [ recipe.output_for_failure_message ]).join("")}" ]
40
+ rescue StandardError
41
+ differences += ["error trying to converge #{resource_name}[#{name}]!\n#{($ERROR_INFO.backtrace.map { |line| "- #{line}\n" } + [recipe.output_for_failure_message]).join('')}"]
43
42
  end
44
43
 
45
44
  # Check for object existence and properties
@@ -1,14 +1,13 @@
1
- require 'rspec/matchers'
2
- require 'aws_support/deep_matcher'
1
+ require "rspec/matchers"
2
+ require "aws_support/deep_matcher"
3
3
 
4
4
  module AWSSupport
5
5
  module Matchers
6
6
  class UpdateAnAWSObject
7
-
8
7
  include RSpec::Matchers::Composable
9
8
  include AWSSupport::DeepMatcher
10
9
 
11
- require 'chef/provisioning'
10
+ require "chef/provisioning"
12
11
 
13
12
  # @param custom_matcher [Block] A block with 1 argument that will be provided the aws_obect
14
13
  def initialize(example, resource_class, name, expected_updates, custom_matcher)
@@ -39,7 +38,7 @@ module AWSSupport
39
38
  def match_failure_messages(recipe)
40
39
  differences = []
41
40
 
42
- if !had_initial_value
41
+ unless had_initial_value
43
42
  differences << "expected recipe to update #{resource_name}[#{name}], but the AWS object did not exist before recipe ran!"
44
43
  return differences
45
44
  end
@@ -47,8 +46,8 @@ module AWSSupport
47
46
  # Converge
48
47
  begin
49
48
  recipe.converge unless recipe.converged?
50
- rescue
51
- differences += [ "error trying to update #{resource_name}[#{name}]!\n#{($!.backtrace.map { |line| "- #{line}\n" } + [ recipe.output_for_failure_message ]).join("")}" ]
49
+ rescue StandardError
50
+ differences += ["error trying to update #{resource_name}[#{name}]!\n#{($ERROR_INFO.backtrace.map { |line| "- #{line}\n" } + [recipe.output_for_failure_message]).join('')}"]
52
51
  end
53
52
 
54
53
  # Check if the recipe actually caused an update
@@ -1,66 +1,68 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsAutoScalingGroup do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server 'exists', organization: 'foo', server_scope: :context do
7
- with_aws 'When connected to AWS' do
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
+ with_aws "When connected to AWS" do
8
8
  # Select an amazon linux ami based upon region
9
9
  ami = {
10
- 'eu-west-1' => 'ami-3850624c',
11
- 'eu-central-1' => 'ami-993383ea',
12
- 'us-east-1' => 'ami-e024bf89',
13
- 'us-west-1' => 'ami-951945d0',
14
- 'us-west-2' => 'ami-16fd7026',
15
- 'ap-northeast-1' => 'ami-dcfa4edd',
16
- 'ap-northeast-2' => 'ami-7308c51d',
17
- 'ap-southeast-1' => 'ami-74dda626',
18
- 'ap-southeast-2' => 'ami-b5990e8f',
19
- 'sa-east-1' => 'ami-3e3be423'
10
+ "eu-west-1" => "ami-3850624c",
11
+ "eu-central-1" => "ami-993383ea",
12
+ "us-east-1" => "ami-e024bf89",
13
+ "us-west-1" => "ami-951945d0",
14
+ "us-west-2" => "ami-16fd7026",
15
+ "ap-northeast-1" => "ami-dcfa4edd",
16
+ "ap-northeast-2" => "ami-7308c51d",
17
+ "ap-southeast-1" => "ami-74dda626",
18
+ "ap-southeast-2" => "ami-b5990e8f",
19
+ "sa-east-1" => "ami-3e3be423"
20
20
  }[driver.region]
21
21
 
22
- aws_launch_configuration 'test_config' do
22
+ aws_launch_configuration "test_config" do
23
23
  image ami
24
- instance_type 't1.micro'
24
+ instance_type "t1.micro"
25
25
  end
26
26
 
27
- aws_sns_topic 'test_topic'
27
+ aws_sns_topic "test_topic"
28
28
 
29
29
  it "aws_auto_scaling_group 'test_group' creates an auto scaling group" do
30
- expect_recipe {
31
- aws_auto_scaling_group 'test_group' do
32
- launch_configuration 'test_config'
30
+ expect_recipe do
31
+ aws_auto_scaling_group "test_group" do
32
+ launch_configuration "test_config"
33
33
  availability_zones ["#{driver.region}a"]
34
34
  min_size 1
35
35
  max_size 2
36
36
  end
37
- }.to create_an_aws_auto_scaling_group(
38
- 'test_group').and be_idempotent
37
+ end.to create_an_aws_auto_scaling_group(
38
+ "test_group"
39
+ ).and be_idempotent
39
40
  end
40
41
 
41
42
  it "aws_auto_scaling_group 'test_group_with_policy' creates an auto scaling group" do
42
- expect_recipe {
43
- aws_auto_scaling_group 'test_group_with_policy' do
44
- launch_configuration 'test_config'
43
+ expect_recipe do
44
+ aws_auto_scaling_group "test_group_with_policy" do
45
+ launch_configuration "test_config"
45
46
  availability_zones ["#{driver.region}a"]
46
47
  min_size 1
47
48
  max_size 2
48
49
  notification_configurations [{
49
- topic: driver.build_arn(service: 'sns', resource: 'test_topic'),
50
+ topic: driver.build_arn(service: "sns", resource: "test_topic"),
50
51
  types: [
51
- 'autoscaling:EC2_INSTANCE_LAUNCH',
52
- 'autoscaling:EC2_INSTANCE_TERMINATE'
52
+ "autoscaling:EC2_INSTANCE_LAUNCH",
53
+ "autoscaling:EC2_INSTANCE_TERMINATE"
53
54
  ]
54
55
  }]
55
56
  scaling_policies(
56
57
  test_policy: {
57
- adjustment_type: 'ChangeInCapacity',
58
+ adjustment_type: "ChangeInCapacity",
58
59
  scaling_adjustment: 1
59
60
  }
60
61
  )
61
62
  end
62
- }.to create_an_aws_auto_scaling_group(
63
- 'test_group_with_policy').and be_idempotent
63
+ end.to create_an_aws_auto_scaling_group(
64
+ "test_group_with_policy"
65
+ ).and be_idempotent
64
66
  end
65
67
 
66
68
  # test_public_subnet
@@ -68,42 +70,37 @@ describe Chef::Resource::AwsAutoScalingGroup do
68
70
  purge_all
69
71
  setup_public_vpc
70
72
  it "creates an aws_auto_scaling_group" do
71
- expect_recipe {
72
- aws_auto_scaling_group 'test_group' do
73
- launch_configuration 'test_config'
73
+ expect_recipe do
74
+ aws_auto_scaling_group "test_group" do
75
+ launch_configuration "test_config"
74
76
  # availability_zones ["#{driver.region}a"]
75
77
  min_size 1
76
78
  max_size 2
77
- options({
78
- subnets: 'test_public_subnet'
79
- })
79
+ options(
80
+ subnets: "test_public_subnet"
81
+ )
80
82
  end
81
- }.to create_an_aws_auto_scaling_group('test_group',
82
- vpc_zone_identifier: test_public_subnet.aws_object.id
83
- ).and be_idempotent
83
+ end.to create_an_aws_auto_scaling_group("test_group",
84
+ vpc_zone_identifier: test_public_subnet.aws_object.id).and be_idempotent
84
85
  end
85
86
  end
86
87
 
87
88
  it "creates aws_auto_scaling_group tags" do
88
- expect_recipe {
89
- aws_auto_scaling_group 'test_group_with_policy' do
90
- launch_configuration 'test_config'
89
+ expect_recipe do
90
+ aws_auto_scaling_group "test_group_with_policy" do
91
+ launch_configuration "test_config"
91
92
  availability_zones ["#{driver.region}a"]
92
93
  min_size 1
93
94
  max_size 2
94
95
  aws_tags key1: "value"
95
96
  end
96
- }.to create_an_aws_auto_scaling_group('test_group_with_policy'
97
- ).and have_aws_auto_scaling_group_tags('test_group_with_policy',
98
- {
99
- 'key1' => 'value'
100
- }
101
- ).and be_idempotent
97
+ end.to create_an_aws_auto_scaling_group("test_group_with_policy").and have_aws_auto_scaling_group_tags("test_group_with_policy",
98
+ "key1" => "value").and be_idempotent
102
99
  end
103
100
 
104
101
  context "with existing tags" do
105
- aws_auto_scaling_group 'test_group_with_policy' do
106
- launch_configuration 'test_config'
102
+ aws_auto_scaling_group "test_group_with_policy" do
103
+ launch_configuration "test_config"
107
104
  availability_zones ["#{driver.region}a"]
108
105
  min_size 1
109
106
  max_size 2
@@ -111,29 +108,24 @@ describe Chef::Resource::AwsAutoScalingGroup do
111
108
  end
112
109
 
113
110
  it "updates aws_auto_scaling_group tags" do
114
- expect_recipe {
115
- aws_auto_scaling_group 'test_group_with_policy' do
111
+ expect_recipe do
112
+ aws_auto_scaling_group "test_group_with_policy" do
116
113
  aws_tags key1: "value2", key2: nil
117
114
  end
118
- }.to have_aws_auto_scaling_group_tags('test_group_with_policy',
119
- {
120
- 'key1' => 'value2',
121
- 'key2' => ''
122
- }
123
- ).and be_idempotent
115
+ end.to have_aws_auto_scaling_group_tags("test_group_with_policy",
116
+ "key1" => "value2",
117
+ "key2" => "").and be_idempotent
124
118
  end
125
119
 
126
120
  it "removes all aws_network_acl tags" do
127
- expect_recipe {
128
- aws_auto_scaling_group 'test_group_with_policy' do
121
+ expect_recipe do
122
+ aws_auto_scaling_group "test_group_with_policy" do
129
123
  aws_tags({})
130
124
  end
131
- }.to have_aws_auto_scaling_group_tags('test_group_with_policy',
132
- {}
133
- ).and be_idempotent
125
+ end.to have_aws_auto_scaling_group_tags("test_group_with_policy",
126
+ {}).and be_idempotent
134
127
  end
135
128
  end
136
-
137
129
  end
138
130
  end
139
131
  end