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
@@ -1,16 +1,14 @@
1
1
  class Chef
2
- module Provisioning
3
- module AWSDriver
4
- module Exceptions
5
-
6
- class MultipleSecurityGroupError < RuntimeError
7
- def initialize(name, groups)
8
- super "Found security groups with ids [#{groups.map {|sg| sg.id}}] that share name #{name}. " \
9
- "Names are unique within VPCs - specify VPC to find by name."
2
+ module Provisioning
3
+ module AWSDriver
4
+ module Exceptions
5
+ class MultipleSecurityGroupError < RuntimeError
6
+ def initialize(name, groups)
7
+ super "Found security groups with ids [#{groups.map(&:id)}] that share name #{name}. " \
8
+ "Names are unique within VPCs - specify VPC to find by name."
9
+ end
10
+ end
11
+ end
10
12
  end
11
13
  end
12
-
13
- end
14
- end
15
- end
16
14
  end
@@ -1,77 +1,77 @@
1
- require 'chef/resource/lwrp_base'
1
+ require "chef/resource/lwrp_base"
2
2
 
3
3
  class Chef
4
- module Provisioning
5
- module AWSDriver
6
- class SuperLWRP < Chef::Resource::LWRPBase
7
- #
8
- # Add the :default lazy { ... } and :coerce validation_opts to `attribute`
9
- #
10
- if self.respond_to?(:properties)
11
- # in Chef 12.5+, properties replace attributes and these respond to
12
- # coerce and default with a lazy block - no need for overwriting!
13
- else
14
- def self.attribute(attr_name, validation_opts={})
15
- if validation_opts[:default].is_a?(Chef::DelayedEvaluator)
16
- lazy_default = validation_opts.delete(:default)
17
- end
18
- coerce = validation_opts.delete(:coerce)
19
- if lazy_default || coerce
20
- define_method(attr_name) do |arg=nil|
21
- arg = instance_exec(arg, &coerce) if coerce && !arg.nil?
4
+ module Provisioning
5
+ module AWSDriver
6
+ class SuperLWRP < Chef::Resource::LWRPBase
7
+ #
8
+ # Add the :default lazy { ... } and :coerce validation_opts to `attribute`
9
+ #
10
+ if respond_to?(:properties)
11
+ # in Chef 12.5+, properties replace attributes and these respond to
12
+ # coerce and default with a lazy block - no need for overwriting!
13
+ else
14
+ def self.attribute(attr_name, validation_opts = {})
15
+ if validation_opts[:default].is_a?(Chef::DelayedEvaluator)
16
+ lazy_default = validation_opts.delete(:default)
17
+ end
18
+ coerce = validation_opts.delete(:coerce)
19
+ if lazy_default || coerce
20
+ define_method(attr_name) do |arg = nil|
21
+ arg = instance_exec(arg, &coerce) if coerce && !arg.nil?
22
22
 
23
- result = set_or_return(attr_name.to_sym, arg, validation_opts)
23
+ result = set_or_return(attr_name.to_sym, arg, validation_opts)
24
24
 
25
- if result.nil? && arg.nil?
26
- result = instance_eval(&lazy_default) if lazy_default
27
- end
25
+ if result.nil? && arg.nil?
26
+ result = instance_eval(&lazy_default) if lazy_default
27
+ end
28
28
 
29
- result
30
- end
31
- define_method(:"#{attr_name}=") do |arg|
32
- if arg.nil?
33
- remove_instance_variable(:"@#{arg}")
29
+ result
30
+ end
31
+ define_method(:"#{attr_name}=") do |arg|
32
+ if arg.nil?
33
+ remove_instance_variable(:"@#{arg}")
34
+ else
35
+ set_or_return(attr_name.to_sym, arg, validation_opts)
36
+ end
37
+ end
34
38
  else
35
- set_or_return(attr_name.to_sym, arg, validation_opts)
39
+ super
36
40
  end
37
41
  end
38
- else
39
- super
40
- end
41
- end
42
42
 
43
- # Below chef 12.5 you cannot do `default lazy: { ... }` - this adds that
44
- def self.lazy(&block)
45
- Chef::DelayedEvaluator.new(&block)
46
- end
47
- end
48
-
49
- # copy from Chef 12.5 params_validate.rb at http://redirx.me/?t35q.
50
- if !method_defined?(:_pv_is)
51
- def _pv_is(opts, key, to_be, raise_error: true)
52
- return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym)
53
- value = _pv_opts_lookup(opts, key)
54
- to_be = [ to_be ].flatten(1)
55
- to_be.each do |tb|
56
- case tb
57
- when Proc
58
- return true if instance_exec(value, &tb)
59
- when Property
60
- validate(opts, { key => tb.validation_options })
61
- return true
62
- else
63
- return true if tb === value
43
+ # Below chef 12.5 you cannot do `default lazy: { ... }` - this adds that
44
+ def self.lazy(&block)
45
+ Chef::DelayedEvaluator.new(&block)
64
46
  end
65
47
  end
66
48
 
67
- if raise_error
68
- raise ::Chef::Exceptions::ValidationFailed, "Option #{key} must be one of: #{to_be.join(", ")}! You passed #{value.inspect}."
69
- else
70
- false
49
+ # copy from Chef 12.5 params_validate.rb at http://redirx.me/?t35q.
50
+ unless method_defined?(:_pv_is)
51
+ def _pv_is(opts, key, to_be, raise_error: true)
52
+ return true if !opts.key?(key.to_s) && !opts.key?(key.to_sym)
53
+ value = _pv_opts_lookup(opts, key)
54
+ to_be = [to_be].flatten(1)
55
+ to_be.each do |tb|
56
+ case tb
57
+ when Proc
58
+ return true if instance_exec(value, &tb)
59
+ when Property
60
+ validate(opts, key => tb.validation_options)
61
+ return true
62
+ else
63
+ return true if tb === value
64
+ end
65
+ end
66
+
67
+ if raise_error
68
+ raise ::Chef::Exceptions::ValidationFailed, "Option #{key} must be one of: #{to_be.join(', ')}! You passed #{value.inspect}."
69
+ else
70
+ false
71
+ end
72
+ end
71
73
  end
72
74
  end
73
75
  end
74
76
  end
75
77
  end
76
- end
77
- end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
 
3
3
  module Chef::Provisioning::AWSDriver::TaggingStrategy
4
4
  module AutoScalingConvergeTags
@@ -12,6 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
12
12
  Chef::Provisioning::AWSDriver::AWSTagger.new(auto_scaling_strategy, action_handler)
13
13
  end
14
14
  end
15
+
15
16
  def converge_tags
16
17
  aws_tagger.converge_tags
17
18
  end
@@ -19,58 +20,56 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
19
20
  end
20
21
 
21
22
  module Chef::Provisioning::AWSDriver::TaggingStrategy
22
- class AutoScaling
23
-
24
- attr_reader :auto_scaling_client, :group_name, :desired_tags
23
+ class AutoScaling
24
+ attr_reader :auto_scaling_client, :group_name, :desired_tags
25
25
 
26
- def initialize(auto_scaling_client, group_name, desired_tags)
27
- @auto_scaling_client = auto_scaling_client
28
- @group_name = group_name
29
- @desired_tags = desired_tags
30
- end
26
+ def initialize(auto_scaling_client, group_name, desired_tags)
27
+ @auto_scaling_client = auto_scaling_client
28
+ @group_name = group_name
29
+ @desired_tags = desired_tags
30
+ end
31
31
 
32
- def current_tags
33
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_tags-instance_method
34
- resp = auto_scaling_client.describe_tags({
35
- filters: [
36
- {
37
- name: "auto-scaling-group",
38
- values: [group_name]
39
- }
40
- ]
41
- })
42
- Hash[resp.tags.map {|t| [t.key, t.value]}]
43
- end
32
+ def current_tags
33
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_tags-instance_method
34
+ resp = auto_scaling_client.describe_tags(
35
+ filters: [
36
+ {
37
+ name: "auto-scaling-group",
38
+ values: [group_name]
39
+ }
40
+ ]
41
+ )
42
+ Hash[resp.tags.map { |t| [t.key, t.value] }]
43
+ end
44
44
 
45
- def set_tags(tags)
46
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_or_update_tags-instance_method
47
- auto_scaling_client.create_or_update_tags({
48
- tags: tags.map {|k,v|
49
- {
50
- resource_id: group_name,
51
- key: k,
52
- value: v,
53
- resource_type: "auto-scaling-group",
54
- propagate_at_launch: false
55
- }
56
- }
57
- })
58
- end
45
+ def set_tags(tags)
46
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_or_update_tags-instance_method
47
+ auto_scaling_client.create_or_update_tags(
48
+ tags: tags.map do |k, v|
49
+ {
50
+ resource_id: group_name,
51
+ key: k,
52
+ value: v,
53
+ resource_type: "auto-scaling-group",
54
+ propagate_at_launch: false
55
+ }
56
+ end
57
+ )
58
+ end
59
59
 
60
- def delete_tags(tag_keys)
61
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#delete_tags-instance_method
62
- auto_scaling_client.delete_tags({
63
- tags: tag_keys.map {|k|
64
- {
65
- resource_id: group_name,
66
- key: k,
67
- value: nil,
68
- resource_type: "auto-scaling-group",
69
- propagate_at_launch: false
70
- }
71
- }
72
- })
60
+ def delete_tags(tag_keys)
61
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#delete_tags-instance_method
62
+ auto_scaling_client.delete_tags(
63
+ tags: tag_keys.map do |k|
64
+ {
65
+ resource_id: group_name,
66
+ key: k,
67
+ value: nil,
68
+ resource_type: "auto-scaling-group",
69
+ propagate_at_launch: false
70
+ }
71
+ end
72
+ )
73
+ end
73
74
  end
74
-
75
- end
76
75
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
 
3
3
  module Chef::Provisioning::AWSDriver::TaggingStrategy
4
4
  module EC2ConvergeTags
@@ -12,6 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
12
12
  Chef::Provisioning::AWSDriver::AWSTagger.new(ec2_strategy, action_handler)
13
13
  end
14
14
  end
15
+
15
16
  def converge_tags
16
17
  aws_tagger.converge_tags
17
18
  end
@@ -19,46 +20,44 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
19
20
  end
20
21
 
21
22
  module Chef::Provisioning::AWSDriver::TaggingStrategy
22
- class EC2
23
-
24
- attr_reader :ec2_client, :aws_object_id, :desired_tags
23
+ class EC2
24
+ attr_reader :ec2_client, :aws_object_id, :desired_tags
25
25
 
26
- def initialize(ec2_client, aws_object_id, desired_tags)
27
- @ec2_client = ec2_client
28
- @aws_object_id = aws_object_id
29
- @desired_tags = desired_tags
30
- end
26
+ def initialize(ec2_client, aws_object_id, desired_tags)
27
+ @ec2_client = ec2_client
28
+ @aws_object_id = aws_object_id
29
+ @desired_tags = desired_tags
30
+ end
31
31
 
32
- def current_tags
33
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_tags-instance_method
34
- resp = ec2_client.describe_tags({
35
- filters: [
36
- {
37
- name: "resource-id",
38
- values: [aws_object_id]
39
- }
40
- ]
41
- })
42
- Hash[resp.tags.map {|t| [t.key, t.value]}]
43
- end
32
+ def current_tags
33
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_tags-instance_method
34
+ resp = ec2_client.describe_tags(
35
+ filters: [
36
+ {
37
+ name: "resource-id",
38
+ values: [aws_object_id]
39
+ }
40
+ ]
41
+ )
42
+ Hash[resp.tags.map { |t| [t.key, t.value] }]
43
+ end
44
44
 
45
- def set_tags(tags)
46
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#create_tags-instance_method
47
- # "The value parameter is required, but if you don't want the tag to have a value, specify
48
- # the parameter with no value, and we set the value to an empty string."
49
- ec2_client.create_tags({
50
- resources: [aws_object_id],
51
- tags: tags.map {|k,v| {key: k, value: v} }
52
- })
53
- end
45
+ def set_tags(tags)
46
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#create_tags-instance_method
47
+ # "The value parameter is required, but if you don't want the tag to have a value, specify
48
+ # the parameter with no value, and we set the value to an empty string."
49
+ ec2_client.create_tags(
50
+ resources: [aws_object_id],
51
+ tags: tags.map { |k, v| { key: k, value: v } }
52
+ )
53
+ end
54
54
 
55
- def delete_tags(tag_keys)
56
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#delete_tags-instance_method
57
- ec2_client.delete_tags({
58
- resources: [aws_object_id],
59
- tags: tag_keys.map {|k| {key: k} }
60
- })
55
+ def delete_tags(tag_keys)
56
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#delete_tags-instance_method
57
+ ec2_client.delete_tags(
58
+ resources: [aws_object_id],
59
+ tags: tag_keys.map { |k| { key: k } }
60
+ )
61
+ end
61
62
  end
62
-
63
- end
64
63
  end
@@ -1,8 +1,7 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
 
3
3
  module Chef::Provisioning::AWSDriver::TaggingStrategy
4
4
  class Elasticsearch
5
-
6
5
  attr_reader :client, :arn, :desired_tags
7
6
 
8
7
  def initialize(client, arn, desired_tags)
@@ -12,29 +11,29 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
12
11
  end
13
12
 
14
13
  def current_tags
15
- resp = client.list_tags({arn: arn})
16
- Hash[resp.tag_list.map {|t| [t.key, t.value]}]
14
+ resp = client.list_tags(arn: arn)
15
+ Hash[resp.tag_list.map { |t| [t.key, t.value] }]
17
16
  rescue ::Aws::ElasticsearchService::Errors::ResourceNotFoundException
18
- Hash.new
17
+ {}
19
18
  end
20
19
 
21
20
  def set_tags(tags)
22
- tags = tags.map {|k,v|
21
+ tags = tags.map do |k, v|
23
22
  if v.nil?
24
- {key: k}
23
+ { key: k }
25
24
  else
26
- {key: k, value: v}
25
+ { key: k, value: v }
27
26
  end
28
- }
29
- client.add_tags({
30
- arn: arn,
31
- tag_list: tags
32
- })
27
+ end
28
+ client.add_tags(
29
+ arn: arn,
30
+ tag_list: tags
31
+ )
33
32
  end
34
33
 
35
34
  def delete_tags(tag_keys)
36
- client.remove_tags({arn: arn,
37
- tag_keys: tag_keys})
35
+ client.remove_tags(arn: arn,
36
+ tag_keys: tag_keys)
38
37
  end
39
38
  end
40
39
  end
@@ -1,39 +1,37 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
 
3
3
  module Chef::Provisioning::AWSDriver::TaggingStrategy
4
- class ELB
4
+ class ELB
5
+ attr_reader :elb_client, :access_point_name, :desired_tags
5
6
 
6
- attr_reader :elb_client, :access_point_name, :desired_tags
7
+ def initialize(elb_client, access_point_name, desired_tags)
8
+ @elb_client = elb_client
9
+ @access_point_name = access_point_name
10
+ @desired_tags = desired_tags
11
+ end
7
12
 
8
- def initialize(elb_client, access_point_name, desired_tags)
9
- @elb_client = elb_client
10
- @access_point_name = access_point_name
11
- @desired_tags = desired_tags
12
- end
13
-
14
- def current_tags
15
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#describe_tags-instance_method
16
- resp = elb_client.describe_tags({
17
- load_balancer_names: [access_point_name]
18
- })
19
- Hash[resp.tag_descriptions[0].tags.map {|t| [t.key, t.value]}]
20
- end
13
+ def current_tags
14
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#describe_tags-instance_method
15
+ resp = elb_client.describe_tags(
16
+ load_balancer_names: [access_point_name]
17
+ )
18
+ Hash[resp.tag_descriptions[0].tags.map { |t| [t.key, t.value] }]
19
+ end
21
20
 
22
- def set_tags(tags)
23
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#add_tags-instance_method
24
- elb_client.add_tags({
25
- load_balancer_names: [access_point_name],
26
- tags: tags.map {|k,v| {key: k, value: v} }
27
- })
28
- end
21
+ def set_tags(tags)
22
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#add_tags-instance_method
23
+ elb_client.add_tags(
24
+ load_balancer_names: [access_point_name],
25
+ tags: tags.map { |k, v| { key: k, value: v } }
26
+ )
27
+ end
29
28
 
30
- def delete_tags(tag_keys)
31
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#remove_tags-instance_method
32
- elb_client.remove_tags({
33
- load_balancer_names: [access_point_name],
34
- tags: tag_keys.map {|k| {key: k} }
35
- })
29
+ def delete_tags(tag_keys)
30
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#remove_tags-instance_method
31
+ elb_client.remove_tags(
32
+ load_balancer_names: [access_point_name],
33
+ tags: tag_keys.map { |k| { key: k } }
34
+ )
35
+ end
36
36
  end
37
-
38
- end
39
37
  end