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,11 +1,9 @@
1
- require_relative 'aws_resource'
1
+ require_relative "aws_resource"
2
2
 
3
3
  module Chef::Provisioning::AWSDriver
4
- class AWSRDSResource < AWSResource
5
-
6
- def rds_tagging_type
7
- raise "You must add the RDS resource type lookup from http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN"
4
+ class AWSRDSResource < AWSResource
5
+ def rds_tagging_type
6
+ raise "You must add the RDS resource type lookup from http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN"
7
+ end
8
8
  end
9
-
10
- end
11
9
  end
@@ -1,212 +1,209 @@
1
- require 'aws-sdk'
2
- require 'chef/provisioning/aws_driver/super_lwrp'
3
- require 'chef/provisioning/chef_managed_entry_store'
1
+ require "aws-sdk"
2
+ require "chef/provisioning/aws_driver/super_lwrp"
3
+ require "chef/provisioning/chef_managed_entry_store"
4
4
  # Enough resources will eventually require this that we put 1 require in here
5
- require 'chef/provisioning/aws_driver/aws_taggable'
5
+ require "chef/provisioning/aws_driver/aws_taggable"
6
6
 
7
7
  # Common AWS resource - contains metadata that all AWS resources will need
8
8
  class Chef
9
- module Provisioning
10
- module AWSDriver
11
- class AWSResource < Chef::Provisioning::AWSDriver::SuperLWRP
12
- actions :create, :destroy, :purge, :nothing
13
- default_action :create
14
-
15
- def initialize(name, run_context=nil)
16
- name = name.public_send(self.class.aws_sdk_class_id) if name.is_a?(self.class.aws_sdk_class)
17
- super
18
- if run_context
19
- driver run_context.chef_provisioning.current_driver
20
- chef_server run_context.cheffish.current_chef_server
21
- end
22
- end
23
-
24
- # Backwards compatibility for action :destroy
25
- def action(*args)
26
- if args == [ :delete ]
27
- super(:destroy)
28
- else
29
- super
30
- end
31
- end
9
+ module Provisioning
10
+ module AWSDriver
11
+ class AWSResource < Chef::Provisioning::AWSDriver::SuperLWRP
12
+ actions :create, :destroy, :purge, :nothing
13
+ default_action :create
14
+
15
+ def initialize(name, run_context = nil)
16
+ name = name.public_send(self.class.aws_sdk_class_id) if name.is_a?(self.class.aws_sdk_class)
17
+ super
18
+ if run_context
19
+ driver run_context.chef_provisioning.current_driver
20
+ chef_server run_context.cheffish.current_chef_server
21
+ end
22
+ end
32
23
 
33
- # In Chef < 12.4 we need to define this method. In > 12.4 this method is
34
- # already defined for us so we don't need to overwrite it.
35
- unless defined?(:action=)
36
- def action=(value)
37
- action(value)
38
- end
39
- end
24
+ # Backwards compatibility for action :destroy
25
+ def action(*args)
26
+ if args == [:delete]
27
+ super(:destroy)
28
+ else
29
+ super
30
+ end
31
+ end
40
32
 
41
- #
42
- # The desired driver.
43
- #
44
- attribute :driver, kind_of: Chef::Provisioning::Driver,
45
- coerce: (proc do |value|
46
- case value
47
- when nil, Chef::Provisioning::Driver
48
- value
49
- else
50
- run_context.chef_provisioning.driver_for(value)
51
- end
52
- end)
53
-
54
- #
55
- # The Chef server on which any IDs should be looked up.
56
- #
57
- attribute :chef_server, kind_of: Hash
58
-
59
- #
60
- # The managed entry store.
61
- #
62
- attribute :managed_entry_store, kind_of: Chef::Provisioning::ManagedEntryStore,
63
- default: lazy { Chef::Provisioning::ChefManagedEntryStore.new(chef_server) }
64
-
65
- #
66
- # Get the current AWS object. This should return the aws_object even if it has
67
- # a status like 'deleted' or 'inactive'. If there is an aws_object, we return it.
68
- # Callers will need to check the status if they care.
69
- #
70
- def aws_object
71
- raise NotImplementedError, :aws_object
72
- end
33
+ # In Chef < 12.4 we need to define this method. In > 12.4 this method is
34
+ # already defined for us so we don't need to overwrite it.
35
+ unless defined?(:action=)
36
+ def action=(value)
37
+ action(value)
38
+ end
39
+ end
73
40
 
74
- def aws_object_id
75
- @aws_object_id ||= begin
76
- o = aws_object
77
- o.public_send(self.class.aws_sdk_class_id) if o
78
- end
79
- end
41
+ #
42
+ # The desired driver.
43
+ #
44
+ attribute :driver, kind_of: Chef::Provisioning::Driver,
45
+ coerce: (proc do |value|
46
+ case value
47
+ when nil, Chef::Provisioning::Driver
48
+ value
49
+ else
50
+ run_context.chef_provisioning.driver_for(value)
51
+ end
52
+ end)
53
+
54
+ #
55
+ # The Chef server on which any IDs should be looked up.
56
+ #
57
+ attribute :chef_server, kind_of: Hash
58
+
59
+ #
60
+ # The managed entry store.
61
+ #
62
+ attribute :managed_entry_store, kind_of: Chef::Provisioning::ManagedEntryStore,
63
+ default: lazy { Chef::Provisioning::ChefManagedEntryStore.new(chef_server) }
64
+
65
+ #
66
+ # Get the current AWS object. This should return the aws_object even if it has
67
+ # a status like 'deleted' or 'inactive'. If there is an aws_object, we return it.
68
+ # Callers will need to check the status if they care.
69
+ #
70
+ def aws_object
71
+ raise NotImplementedError, :aws_object
72
+ end
80
73
 
81
- #
82
- # Look up an AWS options list, translating standard names using the appropriate
83
- # classes.
84
- #
85
- # For example, `load_balancer_options` is passed into `lookup_options`, and if
86
- # it looks like this: `{ subnets: `[ 'subnet1', 'subnet2' ] }`, then
87
- # `AWSResource.lookup_options` will translate each ID with
88
- # `AwsSubnet.get_aws_object('subnet1')`, which supports Chef names
89
- # (`mysubnet`) as well as AWS subnet Ids (`subnet-1234abcd`) or AWS objects
90
- # (`::Aws::EC2::Subnet`).
91
- #
92
- # Keys that represent non-AWS-objects (such as `timeout`) are left alone.
93
- #
94
- def self.lookup_options(options = Hash.new, **handler_options)
95
- options = options.dup
96
- options.each do |name, value|
97
- if name.to_s.end_with?('s')
98
- handler_name = :"#{name[0..-2]}"
99
- if aws_option_handlers[handler_name]
100
- options[name] = [options[name]].flatten.map { |value| aws_option_handlers[handler_name].get_aws_object_id(value, **handler_options) }
74
+ def aws_object_id
75
+ @aws_object_id ||= begin
76
+ o = aws_object
77
+ o.public_send(self.class.aws_sdk_class_id) if o
101
78
  end
102
- else
103
- handler_name = name.to_sym
104
- if aws_option_handlers[handler_name]
105
- options[handler_name] = aws_option_handlers[handler_name].get_aws_object_id(value, **handler_options)
79
+ end
80
+
81
+ #
82
+ # Look up an AWS options list, translating standard names using the appropriate
83
+ # classes.
84
+ #
85
+ # For example, `load_balancer_options` is passed into `lookup_options`, and if
86
+ # it looks like this: `{ subnets: `[ 'subnet1', 'subnet2' ] }`, then
87
+ # `AWSResource.lookup_options` will translate each ID with
88
+ # `AwsSubnet.get_aws_object('subnet1')`, which supports Chef names
89
+ # (`mysubnet`) as well as AWS subnet Ids (`subnet-1234abcd`) or AWS objects
90
+ # (`::Aws::EC2::Subnet`).
91
+ #
92
+ # Keys that represent non-AWS-objects (such as `timeout`) are left alone.
93
+ #
94
+ def self.lookup_options(options = {}, **handler_options)
95
+ options = options.dup
96
+ options.each do |name, value|
97
+ if name.to_s.end_with?("s")
98
+ handler_name = :"#{name[0..-2]}"
99
+ if aws_option_handlers[handler_name]
100
+ options[name] = [options[name]].flatten.map { |value| aws_option_handlers[handler_name].get_aws_object_id(value, **handler_options) }
101
+ end
102
+ else
103
+ handler_name = name.to_sym
104
+ if aws_option_handlers[handler_name]
105
+ options[handler_name] = aws_option_handlers[handler_name].get_aws_object_id(value, **handler_options)
106
+ end
107
+ end
106
108
  end
109
+ options
107
110
  end
108
- end
109
- options
110
- end
111
111
 
112
- def self.get_aws_object(value, resource: nil, run_context: nil, driver: nil, managed_entry_store: nil, required: true)
113
- return nil if value.nil?
112
+ def self.get_aws_object(value, resource: nil, run_context: nil, driver: nil, managed_entry_store: nil, required: true)
113
+ return nil if value.nil?
114
114
 
115
- if resource
116
- run_context ||= resource.run_context
117
- driver ||= resource.driver
118
- managed_entry_store ||= resource.managed_entry_store
119
- end
120
- if value.is_a?(self)
121
- resource = value
122
- else
123
- resource = new(value, run_context)
124
- resource.driver driver if driver
125
- resource.managed_entry_store managed_entry_store if managed_entry_store
126
- end
115
+ if resource
116
+ run_context ||= resource.run_context
117
+ driver ||= resource.driver
118
+ managed_entry_store ||= resource.managed_entry_store
119
+ end
120
+ if value.is_a?(self)
121
+ resource = value
122
+ else
123
+ resource = new(value, run_context)
124
+ resource.driver driver if driver
125
+ resource.managed_entry_store managed_entry_store if managed_entry_store
126
+ end
127
127
 
128
- result = resource.aws_object
129
- if required && result.nil?
130
- raise "#{self}[#{value}] does not exist!"
131
- end
132
- result
133
- end
128
+ result = resource.aws_object
129
+ raise "#{self}[#{value}] does not exist!" if required && result.nil?
130
+ result
131
+ end
134
132
 
135
- def self.get_aws_object_id(value, **options)
136
- aws_object = get_aws_object(value, **options)
137
- aws_object.public_send(aws_sdk_class_id) if aws_object
138
- end
133
+ def self.get_aws_object_id(value, **options)
134
+ aws_object = get_aws_object(value, **options)
135
+ aws_object.public_send(aws_sdk_class_id) if aws_object
136
+ end
139
137
 
140
- protected
141
-
142
- # This supports the introduction of the NOT_PASSED chef constant
143
- # in chef 12.5
144
- # TODO remove when we make 12.5 and higher a dependency
145
- NOT_PASSED = Object.new unless defined?(NOT_PASSED)
146
-
147
- def self.aws_sdk_type(sdk_class,
148
- option_names: nil,
149
- option_name: NOT_PASSED,
150
- load_provider: true,
151
- id: :name,
152
- aws_id_prefix: nil)
153
- self.resource_name = convert_to_snake_case(self.name.split('::')[-1])
154
- @aws_sdk_class = sdk_class
155
- @aws_sdk_class_id = id
156
- @aws_id_prefix = aws_id_prefix
157
-
158
- # Go ahead and require the provider since we're here anyway ...
159
- require "chef/provider/#{resource_name}" if load_provider
160
-
161
- option_name = :"#{resource_name[4..-1]}" if option_name == NOT_PASSED
162
- @aws_sdk_option_name = option_name
163
-
164
- option_names ||= begin
165
- option_names = []
166
- option_names << aws_sdk_option_name
167
- option_names << :"#{option_name}_#{aws_sdk_class_id}" if aws_sdk_class_id
168
- option_names
169
- end
170
- option_names.each do |option_name|
171
- aws_option_handlers[option_name] = self
172
- end
138
+ protected
139
+
140
+ # This supports the introduction of the NOT_PASSED chef constant
141
+ # in chef 12.5
142
+ # TODO remove when we make 12.5 and higher a dependency
143
+ NOT_PASSED = Object.new unless defined?(NOT_PASSED)
144
+
145
+ def self.aws_sdk_type(sdk_class,
146
+ option_names: nil,
147
+ option_name: NOT_PASSED,
148
+ load_provider: true,
149
+ id: :name,
150
+ aws_id_prefix: nil)
151
+ self.resource_name = convert_to_snake_case(name.split("::")[-1])
152
+ @aws_sdk_class = sdk_class
153
+ @aws_sdk_class_id = id
154
+ @aws_id_prefix = aws_id_prefix
155
+
156
+ # Go ahead and require the provider since we're here anyway ...
157
+ require "chef/provider/#{resource_name}" if load_provider
158
+
159
+ option_name = :"#{resource_name[4..-1]}" if option_name == NOT_PASSED
160
+ @aws_sdk_option_name = option_name
161
+
162
+ option_names ||= begin
163
+ option_names = []
164
+ option_names << aws_sdk_option_name
165
+ option_names << :"#{option_name}_#{aws_sdk_class_id}" if aws_sdk_class_id
166
+ option_names
167
+ end
168
+ option_names.each do |option_name|
169
+ aws_option_handlers[option_name] = self
170
+ end
173
171
 
174
- name = self.name.split('::')[-1]
175
- eval("Chef::Provisioning::AWSDriver::Resources::#{name} = self", binding, __FILE__, __LINE__)
176
- end
172
+ name = self.name.split("::")[-1]
173
+ eval("Chef::Provisioning::AWSDriver::Resources::#{name} = self", binding, __FILE__, __LINE__)
174
+ end
177
175
 
178
- def self.aws_sdk_class
179
- @aws_sdk_class
180
- end
176
+ class << self
177
+ attr_reader :aws_sdk_class
178
+ end
181
179
 
182
- def self.aws_sdk_class_id
183
- @aws_sdk_class_id
184
- end
180
+ class << self
181
+ attr_reader :aws_sdk_class_id
182
+ end
185
183
 
186
- def self.aws_id_prefix
187
- @aws_id_prefix
188
- end
184
+ class << self
185
+ attr_reader :aws_id_prefix
186
+ end
189
187
 
190
- def self.aws_sdk_option_name
191
- @aws_sdk_option_name
192
- end
188
+ class << self
189
+ attr_reader :aws_sdk_option_name
190
+ end
193
191
 
194
- @@aws_option_handlers = {}
195
- def self.aws_option_handlers
196
- @@aws_option_handlers
197
- end
192
+ @@aws_option_handlers = {}
193
+ def self.aws_option_handlers
194
+ @@aws_option_handlers
195
+ end
198
196
 
199
- # Add support for aws_id_attribute: true
200
- def self.attribute(name, aws_id_attribute: false, **validation_opts)
201
- @aws_id_attribute = name if aws_id_attribute
202
- super(name, validation_opts)
203
- end
197
+ # Add support for aws_id_attribute: true
198
+ def self.attribute(name, aws_id_attribute: false, **validation_opts)
199
+ @aws_id_attribute = name if aws_id_attribute
200
+ super(name, validation_opts)
201
+ end
204
202
 
205
- def self.aws_id_attribute
206
- @aws_id_attribute
203
+ class << self
204
+ attr_reader :aws_id_attribute
205
+ end
206
+ end
207
207
  end
208
208
  end
209
-
210
- end
211
- end
212
209
  end
@@ -1,9 +1,8 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
2
- require 'chef/provisioning/aws_driver/resources'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
+ require "chef/provisioning/aws_driver/resources"
3
3
 
4
4
  # Common AWS resource - contains metadata that all AWS resources will need
5
5
  class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::AWSDriver::AWSResource
6
-
7
6
  #
8
7
  # Dissociate the ID of this object from Chef.
9
8
  #
@@ -31,11 +30,9 @@ class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::
31
30
  def save_managed_entry(aws_object, action_handler, existing_entry: nil)
32
31
  if should_have_managed_entry?
33
32
  managed_entry = existing_entry ||
34
- managed_entry_store.new_entry(self.class.managed_entry_type, name)
33
+ managed_entry_store.new_entry(self.class.managed_entry_type, name)
35
34
  updated = update_managed_entry(aws_object, managed_entry)
36
- if updated || !existing_entry
37
- managed_entry.save(action_handler)
38
- end
35
+ managed_entry.save(action_handler) if updated || !existing_entry
39
36
  end
40
37
  end
41
38
 
@@ -45,11 +42,11 @@ class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::
45
42
  if entry
46
43
  driver = self.driver
47
44
  if entry.driver_url != driver.driver_url
48
- # TODO some people don't send us run_context (like Drivers). We might need
45
+ # TODO: some people don't send us run_context (like Drivers). We might need
49
46
  # to exit early here if the driver_url doesn't match the provided driver.
50
47
  driver = run_context.chef_provisioning.driver_for(entry.driver_url)
51
48
  end
52
- [ driver, entry.reference[self.class.managed_entry_id_name], entry ]
49
+ [driver, entry.reference[self.class.managed_entry_id_name], entry]
53
50
  end
54
51
  end
55
52
  end
@@ -57,7 +54,7 @@ class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::
57
54
  # Formatted output for logging statements - contains resource type, resource name and aws object id (if available)
58
55
  def to_s
59
56
  id = get_driver_and_id[1]
60
- "#{declared_type}[#{@name}] (#{ id ? id : 'no AWS object id'})"
57
+ "#{declared_type}[#{@name}] (#{id || 'no AWS object id'})"
61
58
  end
62
59
 
63
60
  protected
@@ -83,14 +80,17 @@ class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::
83
80
  def get_driver_and_id
84
81
  driver, id, entry = get_id_from_managed_entry
85
82
  # If the value isn't already stored, look up the user-specified public_ip
86
- driver, id = self.driver, self.public_send(self.class.aws_id_attribute) if !id
87
- [ driver, id ]
83
+ unless id
84
+ driver = self.driver
85
+ id = public_send(self.class.aws_id_attribute)
86
+ end
87
+ [driver, id]
88
88
  end
89
89
 
90
90
  def self.aws_sdk_type(sdk_class,
91
91
  id: :id,
92
92
  managed_entry_type: nil,
93
- managed_entry_id_name: 'id',
93
+ managed_entry_id_name: "id",
94
94
  backcompat_data_bag_name: nil,
95
95
  **options)
96
96
  super(sdk_class, id: id, **options)
@@ -101,12 +101,12 @@ class Chef::Provisioning::AWSDriver::AWSResourceWithEntry < Chef::Provisioning::
101
101
  end
102
102
  end
103
103
 
104
- def self.managed_entry_type
105
- @managed_entry_type
104
+ class << self
105
+ attr_reader :managed_entry_type
106
106
  end
107
107
 
108
- def self.managed_entry_id_name
109
- @managed_entry_id_name
108
+ class << self
109
+ attr_reader :managed_entry_id_name
110
110
  end
111
111
 
112
112
  def should_have_managed_entry?