chef-provisioning-aws 2.2.2 → 3.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/chef-provisioning-aws.gemspec +0 -1
- data/lib/chef/provider/aws_auto_scaling_group.rb +9 -6
- data/lib/chef/provider/aws_dhcp_options.rb +21 -11
- data/lib/chef/provider/aws_ebs_volume.rb +26 -24
- data/lib/chef/provider/aws_eip_address.rb +11 -12
- data/lib/chef/provider/aws_image.rb +1 -1
- data/lib/chef/provider/aws_internet_gateway.rb +18 -10
- data/lib/chef/provider/aws_key_pair.rb +6 -6
- data/lib/chef/provider/aws_launch_configuration.rb +7 -9
- data/lib/chef/provider/aws_nat_gateway.rb +2 -2
- data/lib/chef/provider/aws_network_acl.rb +11 -8
- data/lib/chef/provider/aws_network_interface.rb +34 -29
- data/lib/chef/provider/aws_rds_parameter_group.rb +1 -1
- data/lib/chef/provider/aws_rds_subnet_group.rb +1 -1
- data/lib/chef/provider/aws_route_table.rb +7 -7
- data/lib/chef/provider/aws_s3_bucket.rb +24 -12
- data/lib/chef/provider/aws_security_group.rb +202 -25
- data/lib/chef/provider/aws_server_certificate.rb +3 -4
- data/lib/chef/provider/aws_sns_topic.rb +4 -3
- data/lib/chef/provider/aws_sqs_queue.rb +7 -3
- data/lib/chef/provider/aws_subnet.rb +45 -21
- data/lib/chef/provider/aws_vpc.rb +59 -30
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +12 -3
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +2 -2
- data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +1 -1
- data/lib/chef/provisioning/aws_driver/aws_tagger.rb +2 -2
- data/lib/chef/provisioning/aws_driver/credentials.rb +1 -1
- data/lib/chef/provisioning/aws_driver/credentials2.rb +5 -1
- data/lib/chef/provisioning/aws_driver/driver.rb +124 -34
- data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +4 -4
- data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +1 -1
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_auto_scaling_group.rb +2 -2
- data/lib/chef/resource/aws_cache_cluster.rb +4 -4
- data/lib/chef/resource/aws_cache_replication_group.rb +3 -3
- data/lib/chef/resource/aws_cache_subnet_group.rb +4 -4
- data/lib/chef/resource/aws_cloudsearch_domain.rb +1 -1
- data/lib/chef/resource/aws_cloudwatch_alarm.rb +1 -1
- data/lib/chef/resource/aws_dhcp_options.rb +10 -3
- data/lib/chef/resource/aws_ebs_volume.rb +10 -4
- data/lib/chef/resource/aws_eip_address.rb +4 -4
- data/lib/chef/resource/aws_elasticsearch_domain.rb +1 -1
- data/lib/chef/resource/aws_iam_role.rb +1 -1
- data/lib/chef/resource/aws_internet_gateway.rb +11 -4
- data/lib/chef/resource/aws_key_pair.rb +4 -3
- data/lib/chef/resource/aws_launch_configuration.rb +5 -4
- data/lib/chef/resource/aws_load_balancer.rb +14 -3
- data/lib/chef/resource/aws_nat_gateway.rb +2 -2
- data/lib/chef/resource/aws_network_acl.rb +10 -10
- data/lib/chef/resource/aws_network_interface.rb +12 -6
- data/lib/chef/resource/aws_rds_parameter_group.rb +6 -6
- data/lib/chef/resource/aws_rds_subnet_group.rb +4 -5
- data/lib/chef/resource/aws_route53_record_set.rb +1 -1
- data/lib/chef/resource/aws_route_table.rb +1 -1
- data/lib/chef/resource/aws_s3_bucket.rb +3 -2
- data/lib/chef/resource/aws_security_group.rb +6 -6
- data/lib/chef/resource/aws_server_certificate.rb +4 -5
- data/lib/chef/resource/aws_sns_topic.rb +4 -4
- data/lib/chef/resource/aws_sqs_queue.rb +3 -3
- data/lib/chef/resource/aws_subnet.rb +5 -5
- data/lib/chef/resource/aws_vpc.rb +12 -6
- data/lib/chef/resource/aws_vpc_peering_connection.rb +2 -2
- data/spec/aws_support.rb +12 -9
- data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +15 -5
- data/spec/integration/aws_dhcp_options_spec.rb +7 -7
- data/spec/integration/aws_ebs_volume_spec.rb +1 -1
- data/spec/integration/aws_internet_gateway_spec.rb +19 -18
- data/spec/integration/aws_key_pair_spec.rb +1 -1
- data/spec/integration/aws_nat_gateway_spec.rb +3 -6
- data/spec/integration/aws_network_acl_spec.rb +19 -11
- data/spec/integration/aws_network_interface_spec.rb +26 -20
- data/spec/integration/aws_rds_instance_spec.rb +6 -7
- data/spec/integration/aws_rds_subnet_group_spec.rb +6 -6
- data/spec/integration/aws_route53_hosted_zone_spec.rb +1 -1
- data/spec/integration/aws_s3_bucket_spec.rb +1 -2
- data/spec/integration/aws_security_group_spec.rb +272 -198
- data/spec/integration/aws_server_certificate_spec.rb +60 -78
- data/spec/integration/aws_subnet_spec.rb +8 -4
- data/spec/integration/aws_vpc_spec.rb +29 -23
- data/spec/integration/machine_spec.rb +1 -1
- data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +13 -0
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +1 -1
- data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +1 -1
- metadata +5 -20
- data/spec/persistence_file.txt +0 -220
@@ -98,7 +98,7 @@ module AWSDriver
|
|
98
98
|
|
99
99
|
def load_default
|
100
100
|
config_file = ENV['AWS_CONFIG_FILE'] || File.expand_path('~/.aws/config')
|
101
|
-
credentials_file = ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
|
101
|
+
credentials_file = ENV['AWS_SHARED_CREDENTIALS_FILE'] || ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
|
102
102
|
if File.file?(config_file)
|
103
103
|
if File.file?(credentials_file)
|
104
104
|
load_inis(config_file, credentials_file)
|
@@ -27,7 +27,11 @@ module AWSDriver
|
|
27
27
|
# can be loaded successfully.
|
28
28
|
def get_credentials
|
29
29
|
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
30
|
-
|
30
|
+
credentials_file = ENV.fetch('AWS_SHARED_CREDENTIALS_FILE', ENV['AWS_CONFIG_FILE'])
|
31
|
+
shared_creds = ::Aws::SharedCredentials.new(
|
32
|
+
:profile_name => profile_name,
|
33
|
+
:path => credentials_file
|
34
|
+
)
|
31
35
|
instance_profile_creds = ::Aws::InstanceProfileCredentials.new(:retries => 1)
|
32
36
|
|
33
37
|
if ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"]
|
@@ -20,14 +20,13 @@ require 'chef/provisioning/aws_driver/credentials2'
|
|
20
20
|
require 'chef/provisioning/aws_driver/aws_tagger'
|
21
21
|
|
22
22
|
require 'yaml'
|
23
|
-
require 'aws-sdk-v1'
|
24
23
|
require 'aws-sdk'
|
25
24
|
require 'retryable'
|
26
25
|
require 'ubuntu_ami'
|
27
26
|
require 'base64'
|
28
27
|
|
29
28
|
# loads the entire aws-sdk
|
30
|
-
|
29
|
+
Aws.eager_autoload!
|
31
30
|
AWS_V2_SERVICES = {
|
32
31
|
"EC2" => "ec2",
|
33
32
|
"Route53" => "route53",
|
@@ -112,11 +111,11 @@ module AWSDriver
|
|
112
111
|
region = nil if region && region.empty?
|
113
112
|
|
114
113
|
credentials = profile_name ? aws_credentials[profile_name] : aws_credentials.default
|
115
|
-
@aws_config =
|
114
|
+
@aws_config = Aws.config.update(
|
116
115
|
access_key_id: credentials[:aws_access_key_id],
|
117
116
|
secret_access_key: credentials[:aws_secret_access_key],
|
118
117
|
region: region || credentials[:region],
|
119
|
-
|
118
|
+
http_proxy: credentials[:proxy_uri] || nil,
|
120
119
|
session_token: credentials[:aws_session_token] || nil,
|
121
120
|
logger: Chef::Log.logger
|
122
121
|
)
|
@@ -197,7 +196,7 @@ module AWSDriver
|
|
197
196
|
end
|
198
197
|
|
199
198
|
def rds
|
200
|
-
@rds ||=
|
199
|
+
@rds ||= ::Aws::RDS::Client.new(aws_config)
|
201
200
|
end
|
202
201
|
|
203
202
|
def s3
|
@@ -205,11 +204,11 @@ module AWSDriver
|
|
205
204
|
end
|
206
205
|
|
207
206
|
def sns
|
208
|
-
@sns ||=
|
207
|
+
@sns ||= Aws::SNS::Client.new(config: aws_config)
|
209
208
|
end
|
210
209
|
|
211
210
|
def sqs
|
212
|
-
@sqs ||= AWS::SQS.new(config: aws_config)
|
211
|
+
@sqs ||= AWS::SQS::Client.new(config: aws_config)
|
213
212
|
end
|
214
213
|
|
215
214
|
def auto_scaling
|
@@ -291,10 +290,10 @@ module AWSDriver
|
|
291
290
|
|
292
291
|
old_elb = nil
|
293
292
|
actual_elb = load_balancer_for(lb_spec)
|
294
|
-
if !actual_elb
|
293
|
+
if !actual_elb
|
295
294
|
lb_options[:listeners] ||= get_listeners(:http)
|
296
295
|
if !lb_options[:subnets] && !lb_options[:availability_zones] && machine_specs
|
297
|
-
lb_options[:subnets] = machine_specs.map { |s|
|
296
|
+
lb_options[:subnets] = machine_specs.map { |s| ec2_resource.instances[s.reference['instance_id']].subnet }.uniq
|
298
297
|
end
|
299
298
|
|
300
299
|
perform_action = proc { |desc, &block| action_handler.perform_action(desc, &block) }
|
@@ -309,8 +308,9 @@ module AWSDriver
|
|
309
308
|
|
310
309
|
action_handler.perform_action updates do
|
311
310
|
# IAM says the server certificate exists, but ELB throws this error
|
312
|
-
Chef::Provisioning::AWSDriver::AWSProvider.retry_with_backoff(
|
313
|
-
|
311
|
+
Chef::Provisioning::AWSDriver::AWSProvider.retry_with_backoff(::Aws::ElasticLoadBalancing::Errors::CertificateNotFound) do
|
312
|
+
lb_options[:load_balancer_name]=lb_spec.name
|
313
|
+
actual_elb = elb.create_load_balancer(lb_options)
|
314
314
|
end
|
315
315
|
|
316
316
|
lb_spec.reference = {
|
@@ -334,12 +334,12 @@ module AWSDriver
|
|
334
334
|
|
335
335
|
# Update security groups
|
336
336
|
if lb_options[:security_groups]
|
337
|
-
current = actual_elb.
|
337
|
+
current = actual_elb.security_groups
|
338
338
|
desired = lb_options[:security_groups]
|
339
339
|
if current != desired
|
340
340
|
perform_action.call(" updating security groups to #{desired.to_a}") do
|
341
|
-
|
342
|
-
load_balancer_name: actual_elb.
|
341
|
+
elb_client.apply_security_groups_to_load_balancer(
|
342
|
+
load_balancer_name: actual_elb.load_balancer_name,
|
343
343
|
security_groups: desired.to_a
|
344
344
|
)
|
345
345
|
end
|
@@ -362,7 +362,7 @@ module AWSDriver
|
|
362
362
|
# an unecessary ones
|
363
363
|
actual_zones_subnets = {}
|
364
364
|
actual_elb.subnets.each do |subnet|
|
365
|
-
actual_zones_subnets[subnet
|
365
|
+
actual_zones_subnets[subnet] = Chef::Resource::AwsSubnet.get_aws_object(subnet, driver: self).availability_zone
|
366
366
|
end
|
367
367
|
|
368
368
|
# Only 1 of subnet or AZ will be populated b/c of our check earlier
|
@@ -376,7 +376,7 @@ module AWSDriver
|
|
376
376
|
{:name => 'availabilityZone', :values => [zone]},
|
377
377
|
{:name => 'defaultForAz', :values => ['true']}
|
378
378
|
]
|
379
|
-
default_subnet =
|
379
|
+
default_subnet = ec2_client.describe_subnets(:filters => filters)[:subnets]
|
380
380
|
if default_subnet.size != 1
|
381
381
|
raise "Could not find default subnet in availability zone #{zone}"
|
382
382
|
end
|
@@ -385,7 +385,7 @@ module AWSDriver
|
|
385
385
|
end
|
386
386
|
end
|
387
387
|
unless lb_options[:subnets].nil? || lb_options[:subnets].empty?
|
388
|
-
subnet_query =
|
388
|
+
subnet_query = ec2_client.describe_subnets(:subnet_ids => lb_options[:subnets])[:subnets]
|
389
389
|
# AWS raises an error on an unknown subnet, but not an unknown AZ
|
390
390
|
subnet_query.each do |subnet|
|
391
391
|
zone = subnet[:availability_zone].downcase
|
@@ -405,7 +405,7 @@ module AWSDriver
|
|
405
405
|
load_balancer_name: actual_elb.name,
|
406
406
|
subnets: attach_subnets
|
407
407
|
)
|
408
|
-
rescue
|
408
|
+
rescue ::Aws::ElasticLoadBalancing::Errors::InvalidConfigurationRequest => e
|
409
409
|
Chef::Log.error "You cannot currently move from 1 subnet to another in the same availability zone. " +
|
410
410
|
"Amazon does not have an atomic operation which allows this. You must create a new " +
|
411
411
|
"ELB with the correct subnets and move instances into it. Tried to attach subets " +
|
@@ -433,7 +433,7 @@ module AWSDriver
|
|
433
433
|
# Update listeners - THIS IS NOT ATOMIC
|
434
434
|
if lb_options[:listeners]
|
435
435
|
add_listeners = {}
|
436
|
-
lb_options[:listeners].each { |l| add_listeners[l[:
|
436
|
+
lb_options[:listeners].each { |l| add_listeners[l[:load_balancer_port]] = l }
|
437
437
|
actual_elb.listeners.each do |listener|
|
438
438
|
desired_listener = add_listeners.delete(listener.port)
|
439
439
|
if desired_listener
|
@@ -470,7 +470,7 @@ module AWSDriver
|
|
470
470
|
end
|
471
471
|
end
|
472
472
|
add_listeners.values.each do |listener|
|
473
|
-
updates = [ " add listener #{listener[:
|
473
|
+
updates = [ " add listener #{listener[:load_balanacer_port]}" ]
|
474
474
|
updates << " set protocol to #{listener[:protocol].inspect}"
|
475
475
|
updates << " set instance port to #{listener[:instance_port].inspect}"
|
476
476
|
updates << " set instance protocol to #{listener[:instance_protocol].inspect}"
|
@@ -640,10 +640,10 @@ module AWSDriver
|
|
640
640
|
return if lb_spec == nil
|
641
641
|
|
642
642
|
actual_elb = load_balancer_for(lb_spec)
|
643
|
-
if actual_elb
|
643
|
+
if actual_elb
|
644
644
|
# Remove ELB from AWS
|
645
645
|
action_handler.perform_action "Deleting EC2 ELB #{lb_spec.id}" do
|
646
|
-
actual_elb.
|
646
|
+
elb.delete_load_balancer({load_balancer_name: actual_elb.load_balancer_name })
|
647
647
|
end
|
648
648
|
end
|
649
649
|
|
@@ -868,6 +868,96 @@ EOD
|
|
868
868
|
strategy.cleanup_convergence(action_handler, machine_spec)
|
869
869
|
end
|
870
870
|
|
871
|
+
def cloudsearch(api_version="20130101")
|
872
|
+
@cloudsearch ||= {}
|
873
|
+
@cloudsearch[api_version] ||= ::Aws::CloudSearch::Client.const_get("V#{api_version}").new
|
874
|
+
@cloudsearch[api_version]
|
875
|
+
end
|
876
|
+
|
877
|
+
def ec2
|
878
|
+
@ec2 ||= ::Aws::EC2::Client.new(aws_config)
|
879
|
+
end
|
880
|
+
|
881
|
+
AWS_V2_SERVICES.each do |load_name, short_name|
|
882
|
+
class_eval <<-META
|
883
|
+
|
884
|
+
def #{short_name}_client
|
885
|
+
@#{short_name}_client ||= ::Aws::#{load_name}::Client.new(**aws_config_2)
|
886
|
+
end
|
887
|
+
|
888
|
+
def #{short_name}_resource
|
889
|
+
@#{short_name}_resource ||= ::Aws::#{load_name}::Resource.new(**(aws_config_2.merge({client: #{short_name}_client})))
|
890
|
+
end
|
891
|
+
|
892
|
+
META
|
893
|
+
end
|
894
|
+
|
895
|
+
def elb
|
896
|
+
@elb ||= ::Aws::ElasticLoadBalancing::Client.new(aws_config)
|
897
|
+
end
|
898
|
+
|
899
|
+
def elasticache
|
900
|
+
@elasticache ||= ::Aws::ElastiCache::Client.new(config: aws_config)
|
901
|
+
end
|
902
|
+
|
903
|
+
def iam
|
904
|
+
@iam ||= ::Aws::IAM::Client.new(aws_config)
|
905
|
+
end
|
906
|
+
|
907
|
+
def rds
|
908
|
+
@rds ||= ::Aws::RDS::Client.new(aws_config)
|
909
|
+
end
|
910
|
+
|
911
|
+
def s3_client
|
912
|
+
@s3 ||= ::Aws::S3::Client.new( aws_config)
|
913
|
+
end
|
914
|
+
|
915
|
+
def sns
|
916
|
+
@sns ||= ::Aws::SNS::Client.new(aws_config)
|
917
|
+
end
|
918
|
+
|
919
|
+
def sqs
|
920
|
+
@sqs ||= ::Aws::SQS::Client.new(aws_config)
|
921
|
+
end
|
922
|
+
|
923
|
+
def auto_scaling
|
924
|
+
@auto_scaling ||= ::Aws::AutoScaling.new(config: aws_config)
|
925
|
+
end
|
926
|
+
|
927
|
+
def build_arn(partition: 'aws', service: nil, region: aws_config[:region], account_id: self.account_id, resource: nil)
|
928
|
+
"arn:#{partition}:#{service}:#{region}:#{account_id}:#{resource}"
|
929
|
+
end
|
930
|
+
|
931
|
+
def parse_arn(arn)
|
932
|
+
parts = arn.split(':', 6)
|
933
|
+
{
|
934
|
+
partition: parts[1],
|
935
|
+
service: parts[2],
|
936
|
+
region: parts[3],
|
937
|
+
account_id: parts[4],
|
938
|
+
resource: parts[5]
|
939
|
+
}
|
940
|
+
end
|
941
|
+
|
942
|
+
def account_id
|
943
|
+
begin
|
944
|
+
# We've got an AWS account root credential or an IAM admin with access rights
|
945
|
+
current_user = iam.get_user
|
946
|
+
arn = current_user[:user][:arn]
|
947
|
+
rescue ::Aws::IAM::Errors::AccessDenied => e
|
948
|
+
# If we don't have access, the error message still tells us our account ID and user ...
|
949
|
+
# https://forums.aws.amazon.com/thread.jspa?messageID=394344
|
950
|
+
if e.to_s !~ /\b(arn:aws:iam::[0-9]{12}:\S*)/
|
951
|
+
raise "IAM error response for GetUser did not include user ARN. Can't retrieve account ID."
|
952
|
+
end
|
953
|
+
arn = $1
|
954
|
+
end
|
955
|
+
parse_arn(arn)[:account_id]
|
956
|
+
end
|
957
|
+
|
958
|
+
# For creating things like AWS keypairs exclusively
|
959
|
+
@@chef_default_lock = Mutex.new
|
960
|
+
|
871
961
|
def machine_for(machine_spec, machine_options, instance = nil)
|
872
962
|
instance ||= instance_for(machine_spec)
|
873
963
|
|
@@ -982,9 +1072,9 @@ EOD
|
|
982
1072
|
def keypair_for(bootstrap_options)
|
983
1073
|
if bootstrap_options[:key_name]
|
984
1074
|
keypair_name = bootstrap_options[:key_name]
|
985
|
-
actual_key_pair =
|
1075
|
+
actual_key_pair = ec2_resource.key_pair(keypair_name)
|
986
1076
|
if !actual_key_pair.exists?
|
987
|
-
|
1077
|
+
ec2_resource.key_pairs.create(keypair_name)
|
988
1078
|
end
|
989
1079
|
actual_key_pair
|
990
1080
|
end
|
@@ -1367,7 +1457,7 @@ EOD
|
|
1367
1457
|
instance ||= instance_for(machine_spec)
|
1368
1458
|
sleep_time = 10
|
1369
1459
|
transport = transport_for(machine_spec, machine_options, instance)
|
1370
|
-
unless
|
1460
|
+
unless instance.state.name.eql?("running")
|
1371
1461
|
if action_handler.should_perform_actions
|
1372
1462
|
action_handler.report_progress "waiting for #{machine_spec.name} (#{instance.id} on #{driver_url}) to be connectable (transport up and running) ..."
|
1373
1463
|
max_wait_time = Chef::Config.chef_provisioning[:machine_max_wait_time] || 120
|
@@ -1487,7 +1577,7 @@ EOD
|
|
1487
1577
|
def converge_elb_tags(aws_object, tags, action_handler)
|
1488
1578
|
elb_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::ELB.new(
|
1489
1579
|
elb_client,
|
1490
|
-
aws_object
|
1580
|
+
aws_object,
|
1491
1581
|
tags
|
1492
1582
|
)
|
1493
1583
|
aws_tagger = Chef::Provisioning::AWSDriver::AWSTagger.new(elb_strategy, action_handler)
|
@@ -1553,7 +1643,7 @@ EOD
|
|
1553
1643
|
from.delete(:instance_port)
|
1554
1644
|
from.delete(:instance_protocol)
|
1555
1645
|
to = get_listener(to)
|
1556
|
-
to.delete(:
|
1646
|
+
to.delete(:load_balancer_port)
|
1557
1647
|
to.delete(:protocol)
|
1558
1648
|
to.merge(from)
|
1559
1649
|
end
|
@@ -1573,21 +1663,21 @@ EOD
|
|
1573
1663
|
when Hash
|
1574
1664
|
result.merge!(listener)
|
1575
1665
|
when Array
|
1576
|
-
result[:
|
1666
|
+
result[:load_balancer_port] = listener[0] if listener.size >= 1
|
1577
1667
|
result[:protocol] = listener[1] if listener.size >= 2
|
1578
1668
|
when Symbol,String
|
1579
1669
|
result[:protocol] = listener
|
1580
1670
|
when Integer
|
1581
|
-
result[:
|
1671
|
+
result[:load_balancer_port] = listener
|
1582
1672
|
else
|
1583
1673
|
raise "Invalid listener #{listener}"
|
1584
1674
|
end
|
1585
1675
|
|
1586
1676
|
# If either port or protocol are set, set the other
|
1587
|
-
if result[:
|
1588
|
-
result[:protocol] = PROTOCOL_DEFAULTS[result[:
|
1589
|
-
elsif result[:protocol] && !result[:
|
1590
|
-
result[:
|
1677
|
+
if result[:load_balancer_port] && !result[:protocol]
|
1678
|
+
result[:protocol] = PROTOCOL_DEFAULTS[result[:load_balancer_port]]
|
1679
|
+
elsif result[:protocol] && !result[:load_balancer_port]
|
1680
|
+
result[:load_balancer_port] = PORT_DEFAULTS[result[:protocol]]
|
1591
1681
|
end
|
1592
1682
|
if result[:instance_port] && !result[:instance_protocol]
|
1593
1683
|
result[:instance_protocol] = PROTOCOL_DEFAULTS[result[:instance_port]]
|
@@ -1596,7 +1686,7 @@ EOD
|
|
1596
1686
|
end
|
1597
1687
|
|
1598
1688
|
# If instance_port is still unset, copy port/protocol over
|
1599
|
-
result[:instance_port] ||= result[:
|
1689
|
+
result[:instance_port] ||= result[:load_balancer_port]
|
1600
1690
|
result[:instance_protocol] ||= result[:protocol]
|
1601
1691
|
|
1602
1692
|
result
|
@@ -12,7 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
12
12
|
def aws_tagger
|
13
13
|
@aws_tagger ||= begin
|
14
14
|
rds_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::RDS.new(
|
15
|
-
new_resource.driver.rds
|
15
|
+
new_resource.driver.rds,
|
16
16
|
construct_arn(new_resource),
|
17
17
|
new_resource.aws_tags
|
18
18
|
)
|
@@ -26,15 +26,15 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
26
26
|
# http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN
|
27
27
|
def construct_arn(new_resource)
|
28
28
|
@arn ||= begin
|
29
|
-
region = new_resource.driver.region
|
29
|
+
region = new_resource.driver.aws_config[:region]
|
30
30
|
name = new_resource.name
|
31
31
|
rds_type = new_resource.rds_tagging_type
|
32
32
|
# Taken from example on https://forums.aws.amazon.com/thread.jspa?threadID=108012
|
33
33
|
account_id = begin
|
34
|
-
u = new_resource.driver.iam.
|
34
|
+
u = new_resource.driver.iam.get_user
|
35
35
|
# We've got an AWS account root credential or an IAM admin with access rights
|
36
36
|
u[:user][:arn].match('^arn:aws:iam::([0-9]{12}):.*$')[1]
|
37
|
-
rescue
|
37
|
+
rescue ::Aws::IAM::Errors::AccessDenied => e
|
38
38
|
# We've got an AWS IAM Credential
|
39
39
|
e.to_s.match('^User: arn:aws:iam::([0-9]{12}):.*$')[1]
|
40
40
|
end
|
@@ -3,7 +3,7 @@ require 'chef/provisioning/aws_driver/aws_resource'
|
|
3
3
|
class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSResource
|
4
4
|
include Chef::Provisioning::AWSDriver::AWSTaggable
|
5
5
|
|
6
|
-
aws_sdk_type
|
6
|
+
aws_sdk_type ::Aws::AutoScaling::AutoScalingGroup
|
7
7
|
|
8
8
|
attribute :name, kind_of: String, name_attribute: true
|
9
9
|
attribute :options, kind_of: Hash, default: {}
|
@@ -17,7 +17,7 @@ class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSRe
|
|
17
17
|
attribute :scaling_policies, kind_of: Hash, default: {}
|
18
18
|
|
19
19
|
def aws_object
|
20
|
-
result = driver.
|
20
|
+
result = driver.auto_scaling_resource.group(name)
|
21
21
|
result && result.exists? ? result : nil
|
22
22
|
end
|
23
23
|
end
|
@@ -6,7 +6,7 @@ require 'chef/resource/aws_security_group'
|
|
6
6
|
# @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_cluster-instance_method
|
7
7
|
class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResource
|
8
8
|
# Note: There isn't actually an SDK class for Elasticache.
|
9
|
-
aws_sdk_type
|
9
|
+
aws_sdk_type ::Aws::ElastiCache
|
10
10
|
|
11
11
|
# See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_cluster-instance_method
|
12
12
|
# for information on possible values for each attribute. Values are passed
|
@@ -63,9 +63,9 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
|
|
63
63
|
|
64
64
|
# Security Groups
|
65
65
|
#
|
66
|
-
# @param :security_groups [String, Array, AwsSecurityGroup,
|
66
|
+
# @param :security_groups [String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup] one or more VPC security groups associated with the cache cluster.
|
67
67
|
attribute :security_groups,
|
68
|
-
kind_of: [ String, Array, AwsSecurityGroup,
|
68
|
+
kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
|
69
69
|
required: true,
|
70
70
|
coerce: proc { |v| [v].flatten }
|
71
71
|
|
@@ -74,7 +74,7 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
|
|
74
74
|
driver.elasticache
|
75
75
|
.describe_cache_clusters(cache_cluster_id: cluster_name)
|
76
76
|
.data[:cache_clusters].first
|
77
|
-
rescue
|
77
|
+
rescue ::Aws::ElastiCache::Errors::CacheClusterNotFound
|
78
78
|
nil
|
79
79
|
end
|
80
80
|
end
|
@@ -5,7 +5,7 @@ require 'chef/resource/aws_security_group'
|
|
5
5
|
# @see See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
|
6
6
|
class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::AWSResource
|
7
7
|
# Note: There isn't actually an SDK class for Elasticache.
|
8
|
-
aws_sdk_type
|
8
|
+
aws_sdk_type ::Aws::ElastiCache
|
9
9
|
|
10
10
|
# See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
|
11
11
|
# for information on possible values for each attribute. Values are passed
|
@@ -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,
|
59
|
+
kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
|
60
60
|
required: true,
|
61
61
|
coerce: proc { |v| [v].flatten }
|
62
62
|
|
@@ -72,7 +72,7 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
|
|
72
72
|
driver.elasticache
|
73
73
|
.describe_replication_groups(replication_group_id: group_name)
|
74
74
|
.data[:replication_groups].first
|
75
|
-
rescue
|
75
|
+
rescue ::Aws::ElastiCache::Errors::ReplicationGroupNotFoundFault
|
76
76
|
nil
|
77
77
|
end
|
78
78
|
end
|