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,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
 
3
3
  ####################
4
4
  # NOTE FROM http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html
@@ -19,6 +19,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
19
19
  Chef::Provisioning::AWSDriver::AWSTagger.new(rds_strategy, action_handler)
20
20
  end
21
21
  end
22
+
22
23
  def converge_tags
23
24
  aws_tagger.converge_tags
24
25
  end
@@ -33,10 +34,10 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
33
34
  account_id = begin
34
35
  u = new_resource.driver.iam.get_user
35
36
  # We've got an AWS account root credential or an IAM admin with access rights
36
- u[:user][:arn].match('^arn:aws:iam::([0-9]{12}):.*$')[1]
37
+ u[:user][:arn].match("^arn:aws:iam::([0-9]{12}):.*$")[1]
37
38
  rescue ::Aws::IAM::Errors::AccessDenied => e
38
39
  # We've got an AWS IAM Credential
39
- e.to_s.match('^User: arn:aws:iam::([0-9]{12}):.*$')[1]
40
+ e.to_s.match("^User: arn:aws:iam::([0-9]{12}):.*$")[1]
40
41
  end
41
42
  # arn:aws:rds:<region>:<account number>:<resourcetype>:<name>
42
43
  "arn:aws:rds:#{region}:#{account_id}:#{rds_type}:#{name}"
@@ -46,47 +47,45 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
46
47
  end
47
48
 
48
49
  module Chef::Provisioning::AWSDriver::TaggingStrategy
49
- class RDS
50
-
51
- attr_reader :rds_client, :rds_object_arn, :desired_tags
50
+ class RDS
51
+ attr_reader :rds_client, :rds_object_arn, :desired_tags
52
52
 
53
- def initialize(rds_client, rds_object_arn, desired_tags)
54
- @rds_client = rds_client
55
- @rds_object_arn = rds_object_arn
56
- @desired_tags = desired_tags
57
- end
53
+ def initialize(rds_client, rds_object_arn, desired_tags)
54
+ @rds_client = rds_client
55
+ @rds_object_arn = rds_object_arn
56
+ @desired_tags = desired_tags
57
+ end
58
58
 
59
- def current_tags
60
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#list_tags_for_resource-instance_method
61
- resp = rds_client.list_tags_for_resource({
62
- resource_name: rds_object_arn
63
- })
64
- Hash[resp.tag_list.map {|t| [t.key, t.value]}]
65
- end
59
+ def current_tags
60
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#list_tags_for_resource-instance_method
61
+ resp = rds_client.list_tags_for_resource(
62
+ resource_name: rds_object_arn
63
+ )
64
+ Hash[resp.tag_list.map { |t| [t.key, t.value] }]
65
+ end
66
66
 
67
- def set_tags(tags)
68
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#add_tags_to_resource-instance_method
69
- # Unlike EC2, RDS tags can have a nil value
70
- tags = tags.map {|k,v|
71
- if v.nil?
72
- {key: k}
73
- else
74
- {key: k, value: v}
67
+ def set_tags(tags)
68
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#add_tags_to_resource-instance_method
69
+ # Unlike EC2, RDS tags can have a nil value
70
+ tags = tags.map do |k, v|
71
+ if v.nil?
72
+ { key: k }
73
+ else
74
+ { key: k, value: v }
75
+ end
75
76
  end
76
- }
77
- rds_client.add_tags_to_resource({
78
- resource_name: rds_object_arn,
79
- tags: tags
80
- })
81
- end
77
+ rds_client.add_tags_to_resource(
78
+ resource_name: rds_object_arn,
79
+ tags: tags
80
+ )
81
+ end
82
82
 
83
- def delete_tags(tag_keys)
84
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#remove_tags_from_resource-instance_method
85
- rds_client.remove_tags_from_resource({
86
- resource_name: rds_object_arn,
87
- tag_keys: tag_keys
88
- })
83
+ def delete_tags(tag_keys)
84
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#remove_tags_from_resource-instance_method
85
+ rds_client.remove_tags_from_resource(
86
+ resource_name: rds_object_arn,
87
+ tag_keys: tag_keys
88
+ )
89
+ end
89
90
  end
90
-
91
- end
92
91
  end
@@ -1,51 +1,49 @@
1
- require 'chef/provisioning/aws_driver/aws_tagger'
1
+ require "chef/provisioning/aws_driver/aws_tagger"
2
2
  module Chef::Provisioning::AWSDriver::TaggingStrategy
3
- class S3
3
+ class S3
4
+ attr_reader :s3_client, :bucket_name, :desired_tags
4
5
 
5
- attr_reader :s3_client, :bucket_name, :desired_tags
6
-
7
- def initialize(s3_client, bucket_name, desired_tags)
8
- @s3_client = s3_client
9
- @bucket_name = bucket_name
10
- @desired_tags = desired_tags
11
- end
6
+ def initialize(s3_client, bucket_name, desired_tags)
7
+ @s3_client = s3_client
8
+ @bucket_name = bucket_name
9
+ @desired_tags = desired_tags
10
+ end
12
11
 
13
- def current_tags
14
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#get_bucket_tagging-instance_method
15
- resp = s3_client.get_bucket_tagging({
16
- bucket: bucket_name
17
- })
18
- Hash[resp.tag_set.map {|t| [t.key, t.value]}]
19
- rescue ::Aws::S3::Errors::NoSuchTagSet => e
20
- # Instead of returning nil or empty, AWS raises an error :)
21
- {}
22
- end
12
+ def current_tags
13
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#get_bucket_tagging-instance_method
14
+ resp = s3_client.get_bucket_tagging(
15
+ bucket: bucket_name
16
+ )
17
+ Hash[resp.tag_set.map { |t| [t.key, t.value] }]
18
+ rescue ::Aws::S3::Errors::NoSuchTagSet => e
19
+ # Instead of returning nil or empty, AWS raises an error :)
20
+ {}
21
+ end
23
22
 
24
- def set_tags(tags)
25
- return if @is_set_tag
26
- # It will also run from delete_tags to prevent two times execution of same api class variable is defined
27
- @is_set_tag = true
28
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#put_bucket_tagging-instance_method
29
- s3_client.put_bucket_tagging({
30
- bucket: bucket_name,
31
- tagging: {
32
- tag_set: desired_tags.map {|k,v| {key: k.to_s, value: v.to_s} }
33
- }
34
- })
35
- end
23
+ def set_tags(_tags)
24
+ return if @is_set_tag
25
+ # It will also run from delete_tags to prevent two times execution of same api class variable is defined
26
+ @is_set_tag = true
27
+ # http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#put_bucket_tagging-instance_method
28
+ s3_client.put_bucket_tagging(
29
+ bucket: bucket_name,
30
+ tagging: {
31
+ tag_set: desired_tags.map { |k, v| { key: k.to_s, value: v.to_s } }
32
+ }
33
+ )
34
+ end
36
35
 
37
- def delete_tags(tag_keys)
38
- if desired_tags.empty?
39
- s3_client.delete_bucket_tagging({
40
- bucket: bucket_name
41
- })
42
- else
43
- set_tags(desired_tags)
36
+ def delete_tags(_tag_keys)
37
+ if desired_tags.empty?
38
+ s3_client.delete_bucket_tagging(
39
+ bucket: bucket_name
40
+ )
41
+ else
42
+ set_tags(desired_tags)
43
+ end
44
+ # S3 doesn't have a client action for deleting individual tags, just ALL tags. But the
45
+ # put_bucket_tagging method will set the tags to what is provided so we don't need to
46
+ # worry about this
44
47
  end
45
- # S3 doesn't have a client action for deleting individual tags, just ALL tags. But the
46
- # put_bucket_tagging method will set the tags to what is provided so we don't need to
47
- # worry about this
48
48
  end
49
-
50
- end
51
49
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
- module Provisioning
3
- module AWSDriver
4
- VERSION = '3.0.4'
5
- end
6
- end
2
+ module Provisioning
3
+ module AWSDriver
4
+ VERSION = "3.0.6".freeze
5
+ end
6
+ end
7
7
  end
@@ -1,3 +1,3 @@
1
- require 'chef/provisioning/aws_driver'
1
+ require "chef/provisioning/aws_driver"
2
2
 
3
- Chef::Provisioning.register_driver_class('aws', Chef::Provisioning::AWSDriver::Driver)
3
+ Chef::Provisioning.register_driver_class("aws", Chef::Provisioning::AWSDriver::Driver)
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
2
 
3
3
  class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSResource
4
4
  include Chef::Provisioning::AWSDriver::AWSTaggable
@@ -1,5 +1,5 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
2
- require 'chef/resource/aws_security_group'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
+ require "chef/resource/aws_security_group"
3
3
 
4
4
  # AWS Elasticache Cluster
5
5
  #
@@ -32,10 +32,9 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
32
32
  #
33
33
  # @param :preferred_availability_zones [String, Array] One or more preferred availability zones
34
34
  attribute :preferred_availability_zones,
35
- kind_of: [ String, Array ],
35
+ kind_of: [String, Array],
36
36
  coerce: proc { |v| [v].flatten }
37
37
 
38
-
39
38
  # Number of Nodes
40
39
  #
41
40
  # @param :number_nodes [Integer] Number of nodes in the cache
@@ -65,17 +64,15 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
65
64
  #
66
65
  # @param :security_groups [String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup] one or more VPC security groups associated with the cache cluster.
67
66
  attribute :security_groups,
68
- kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
67
+ kind_of: [String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup],
69
68
  required: true,
70
69
  coerce: proc { |v| [v].flatten }
71
70
 
72
71
  def aws_object
73
- begin
74
- driver.elasticache
75
- .describe_cache_clusters(cache_cluster_id: cluster_name)
76
- .data[:cache_clusters].first
77
- rescue ::Aws::ElastiCache::Errors::CacheClusterNotFound
78
- nil
79
- end
72
+ driver.elasticache
73
+ .describe_cache_clusters(cache_cluster_id: cluster_name)
74
+ .data[:cache_clusters].first
75
+ rescue ::Aws::ElastiCache::Errors::CacheClusterNotFound
76
+ nil
80
77
  end
81
78
  end
@@ -1,5 +1,5 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
2
- require 'chef/resource/aws_security_group'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
+ require "chef/resource/aws_security_group"
3
3
 
4
4
  # AWS Elasticache Replication Group
5
5
  # @see See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
@@ -56,7 +56,7 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
56
56
  #
57
57
  # @param
58
58
  attribute :security_groups,
59
- kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
59
+ kind_of: [String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup],
60
60
  required: true,
61
61
  coerce: proc { |v| [v].flatten }
62
62
 
@@ -64,16 +64,14 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
64
64
  #
65
65
  # @param
66
66
  attribute :preferred_availability_zones,
67
- kind_of: [ String, Array ],
67
+ kind_of: [String, Array],
68
68
  coerce: proc { |v| [v].flatten }
69
69
 
70
70
  def aws_object
71
- begin
72
- driver.elasticache
73
- .describe_replication_groups(replication_group_id: group_name)
74
- .data[:replication_groups].first
75
- rescue ::Aws::ElastiCache::Errors::ReplicationGroupNotFoundFault
76
- nil
77
- end
71
+ driver.elasticache
72
+ .describe_replication_groups(replication_group_id: group_name)
73
+ .data[:replication_groups].first
74
+ rescue ::Aws::ElastiCache::Errors::ReplicationGroupNotFoundFault
75
+ nil
78
76
  end
79
77
  end
@@ -1,5 +1,5 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
2
- require 'chef/resource/aws_subnet'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
+ require "chef/resource/aws_subnet"
3
3
 
4
4
  # AWS Elasticache Subnet Group
5
5
  # @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_subnet_group-instance_method
@@ -26,17 +26,15 @@ class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSRe
26
26
  #
27
27
  # @param :subnets [ String, Array, AwsSubnet, ::Aws::EC2::Subnet ] One or more subnets in the subnet group.
28
28
  attribute :subnets,
29
- kind_of: [ String, Array, AwsSubnet, ::Aws::EC2::Subnet ],
29
+ kind_of: [String, Array, AwsSubnet, ::Aws::EC2::Subnet],
30
30
  required: true,
31
31
  coerce: proc { |v| [v].flatten }
32
32
 
33
33
  def aws_object
34
- begin
35
- driver.elasticache
36
- .describe_cache_subnet_groups(cache_subnet_group_name: group_name)
37
- .data[:cache_subnet_groups].first
38
- rescue ::Aws::ElastiCache::Errors::CacheSubnetGroupNotFoundFault
39
- nil
40
- end
34
+ driver.elasticache
35
+ .describe_cache_subnet_groups(cache_subnet_group_name: group_name)
36
+ .data[:cache_subnet_groups].first
37
+ rescue ::Aws::ElastiCache::Errors::CacheSubnetGroupNotFoundFault
38
+ nil
41
39
  end
42
40
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
2
 
3
3
  module AWS
4
4
  class CloudSearch
@@ -13,7 +13,7 @@ end
13
13
  class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSResource
14
14
  aws_sdk_type ::Aws::CloudSearchDomain
15
15
  attribute :name, kind_of: String, name_attribute: true
16
- attribute :cloudsearch_api_version, equal_to: ["20130101", "20110201"], default: "20130101"
16
+ attribute :cloudsearch_api_version, equal_to: %w{20130101 20110201}, default: "20130101"
17
17
 
18
18
  # Availability Options
19
19
  attribute :multi_az, kind_of: [TrueClass, FalseClass], default: false
@@ -30,7 +30,6 @@ class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSR
30
30
  # For now we just allow the user to shove the policy in via a string.
31
31
  attribute :access_policies, kind_of: String
32
32
 
33
-
34
33
  # Indexing Options
35
34
  # TODO(ssd): Like Access Polcies, we should decide
36
35
  # whether we want a DSL for defining index fields, or just allow the
@@ -41,10 +40,10 @@ class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSR
41
40
  # objects in the version of the AWS API we are using. This will
42
41
  # return a hash with some relevant information about the domain.
43
42
  def aws_object
44
- driver.cloudsearch.describe_domains(domain_names: [name])[:domain_status_list].find {|d| !d[:deleted] }
43
+ driver.cloudsearch.describe_domains(domain_names: [name])[:domain_status_list].find { |d| !d[:deleted] }
45
44
  end
46
45
 
47
- def cloudsearch_api_version(arg=nil)
46
+ def cloudsearch_api_version(arg = nil)
48
47
  unless arg.nil?
49
48
  Chef::Log.warn("The ':cloudsearch_api_version' has been deprecated since it has been removed in AWS SDK version 2.")
50
49
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_resource'
1
+ require "chef/provisioning/aws_driver/aws_resource"
2
2
 
3
3
  class Chef::Resource::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSResource
4
4
  include Chef::Provisioning::AWSDriver::AWSTaggable
@@ -6,24 +6,24 @@ class Chef::Resource::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSRes
6
6
  aws_sdk_type ::Aws::CloudWatch::Alarm, id: :name
7
7
 
8
8
  # This name must be unique within the user's AWS account
9
- attribute :name, :kind_of => String, :name_attribute => true
10
- attribute :namespace, :kind_of => String
11
- attribute :metric_name, :kind_of => String
12
- attribute :dimensions, :kind_of => Array
13
- attribute :comparison_operator, :kind_of => String
14
- attribute :evaluation_periods, :kind_of => Integer
15
- attribute :period, :kind_of => [Integer,Float], coerce: proc {|v| v.to_f}
16
- attribute :statistic, :kind_of => String
17
- attribute :threshold, :kind_of => [Integer,Float]
18
- attribute :insufficient_data_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
19
- attribute :ok_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
20
- attribute :alarm_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
21
- attribute :actions_enabled, :kind_of => [TrueClass, FalseClass]
22
- attribute :alarm_description, :kind_of => String
23
- attribute :unit, :kind_of => String
9
+ attribute :name, kind_of: String, name_attribute: true
10
+ attribute :namespace, kind_of: String
11
+ attribute :metric_name, kind_of: String
12
+ attribute :dimensions, kind_of: Array
13
+ attribute :comparison_operator, kind_of: String
14
+ attribute :evaluation_periods, kind_of: Integer
15
+ attribute :period, kind_of: [Integer, Float], coerce: proc { |v| v.to_f }
16
+ attribute :statistic, kind_of: String
17
+ attribute :threshold, kind_of: [Integer, Float]
18
+ attribute :insufficient_data_actions, kind_of: Array, coerce: proc { |v| [v].flatten }
19
+ attribute :ok_actions, kind_of: Array, coerce: proc { |v| [v].flatten }
20
+ attribute :alarm_actions, kind_of: Array, coerce: proc { |v| [v].flatten }
21
+ attribute :actions_enabled, kind_of: [TrueClass, FalseClass]
22
+ attribute :alarm_description, kind_of: String
23
+ attribute :unit, kind_of: String
24
24
 
25
25
  def aws_object
26
- # TODO exists? isn't defined yet
26
+ # TODO: exists? isn't defined yet
27
27
  # https://github.com/aws/aws-sdk-ruby/issues/1171
28
28
  a = driver.cloudwatch_resource.alarm(name)
29
29
  return nil if a.data.nil?
@@ -31,5 +31,4 @@ class Chef::Resource::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSRes
31
31
  rescue ::Aws::CloudWatch::Errors::NoSuchEntity
32
32
  nil
33
33
  end
34
-
35
34
  end
@@ -1,4 +1,4 @@
1
- require 'chef/provisioning/aws_driver/aws_resource_with_entry'
1
+ require "chef/provisioning/aws_driver/aws_resource_with_entry"
2
2
 
3
3
  #
4
4
  # DHCP options for use by VPCs.
@@ -61,6 +61,6 @@ class Chef::Resource::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSResourc
61
61
  def exists?(result)
62
62
  return true if result.data
63
63
  rescue ::Aws::EC2::Errors::InvalidDhcpOptionIDNotFound
64
- return false
64
+ false
65
65
  end
66
66
  end
@@ -1,22 +1,22 @@
1
- require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
- require 'chef/resource/aws_instance'
1
+ require "chef/provisioning/aws_driver/aws_resource_with_entry"
2
+ require "chef/resource/aws_instance"
3
3
 
4
4
  class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
5
5
  include Chef::Provisioning::AWSDriver::AWSTaggable
6
6
 
7
- aws_sdk_type ::Aws::EC2::Volume, backcompat_data_bag_name: 'ebs_volumes'
7
+ aws_sdk_type ::Aws::EC2::Volume, backcompat_data_bag_name: "ebs_volumes"
8
8
 
9
- attribute :name, kind_of: String, name_attribute: true
9
+ attribute :name, kind_of: String, name_attribute: true
10
10
 
11
- attribute :machine, kind_of: [ String, FalseClass, AwsInstance, ::Aws::EC2::Instance, ::Aws::EC2::Instance ]
11
+ attribute :machine, kind_of: [String, FalseClass, AwsInstance, ::Aws::EC2::Instance, ::Aws::EC2::Instance]
12
12
 
13
- attribute :availability_zone, kind_of: String, default: 'a'
13
+ attribute :availability_zone, kind_of: String, default: "a"
14
14
  attribute :size, kind_of: Integer, default: 8
15
15
  attribute :snapshot, kind_of: String
16
16
 
17
17
  attribute :iops, kind_of: Integer
18
18
  attribute :volume_type, kind_of: String
19
- attribute :encrypted, kind_of: [ TrueClass, FalseClass ]
19
+ attribute :encrypted, kind_of: [TrueClass, FalseClass]
20
20
  attribute :device, kind_of: String
21
21
 
22
22
  attribute :volume_id, kind_of: String, aws_id_attribute: true, default: lazy {
@@ -26,12 +26,12 @@ class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceW
26
26
  def aws_object
27
27
  driver, id = get_driver_and_id
28
28
  result = driver.ec2_resource.volume(id) if id
29
- result && exists?(result) && ![:deleted, :deleting].include?(result.state) ? result : nil
29
+ result && exists?(result) && !%i{deleted deleting}.include?(result.state) ? result : nil
30
30
  end
31
-
31
+
32
32
  def exists?(result)
33
33
  return true if result.data
34
34
  rescue ::Aws::EC2::Errors::InvalidVolumeNotFound
35
- return false
35
+ false
36
36
  end
37
37
  end