chef-provisioning-aws 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chef/provider/aws_eip_address.rb +85 -0
- data/lib/chef/provider/aws_key_pair.rb +1 -1
- data/lib/chef/provider/aws_s3_bucket.rb +35 -5
- data/lib/chef/provisioning/aws_driver/credentials.rb +36 -8
- data/lib/chef/provisioning/aws_driver/driver.rb +22 -6
- data/lib/chef/provisioning/aws_driver/resources.rb +1 -1
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_eip_address.rb +29 -0
- data/lib/chef/resource/aws_s3_bucket.rb +2 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/unit/aws_driver/credentials_spec.rb +109 -0
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eda6856be96232e40cce33671b0ed5b92ea9b693
|
4
|
+
data.tar.gz: 58a87deccbffab115c4799f7244030e1d60021d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b18ddd408a632dd03005160807a3fd398f9326009df0dfe27b270860a0beeba6173bca3c39feec22b990ead226075e1507fa35b89689a4d98078341658952b
|
7
|
+
data.tar.gz: ef03d0848060e8bc2097eba525cc33f61d22fcc5ee544205f3ba09af55b75ea8597dc654c41f8d471a216a89900edef409a95b606a20d066a3e2e44b7f8b7a64
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'chef/provider/aws_provider'
|
2
|
+
require 'chef/provisioning/machine_spec'
|
3
|
+
require 'cheffish'
|
4
|
+
|
5
|
+
class Chef::Provider::AwsEipAddress < Chef::Provider::AwsProvider
|
6
|
+
|
7
|
+
action :create do
|
8
|
+
if existing_ip == nil
|
9
|
+
converge_by "Creating new EIP address in #{new_resource.region_name}" do
|
10
|
+
eip = ec2.elastic_ips.create :vpc => new_resource.associate_to_vpc
|
11
|
+
new_resource.public_ip eip.public_ip
|
12
|
+
new_resource.domain eip.domain
|
13
|
+
new_resource.instance_id eip.instance_id
|
14
|
+
end
|
15
|
+
else
|
16
|
+
new_resource.public_ip existing_ip.public_ip
|
17
|
+
new_resource.domain existing_ip.domain
|
18
|
+
new_resource.instance_id existing_ip.instance_id
|
19
|
+
end
|
20
|
+
new_resource.save
|
21
|
+
end
|
22
|
+
|
23
|
+
action :delete do
|
24
|
+
if existing_ip
|
25
|
+
converge_by "Deleting EIP Address #{new_resource.name} in #{new_resource.region_name}" do
|
26
|
+
#if it's attached to something in a vpc, disassociate first
|
27
|
+
if existing_ip.instance_id != nil && existing_ip.domain == 'vpc'
|
28
|
+
existing_ip.disassociate
|
29
|
+
end
|
30
|
+
existing_ip.delete
|
31
|
+
new_resource.delete
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
action :associate do
|
37
|
+
converge_by "Associating EIP Address #{new_resource.name} in #{new_resource.region_name}" do
|
38
|
+
if existing_ip == nil
|
39
|
+
action_create
|
40
|
+
end
|
41
|
+
eip = ec2.elastic_ips[new_resource.public_ip]
|
42
|
+
begin
|
43
|
+
spec = Chef::Provisioning::ChefMachineSpec.get(new_resource.machine)
|
44
|
+
if spec == nil
|
45
|
+
Chef::Application.fatal!("Could not find machine #{new_resource.machine}")
|
46
|
+
else
|
47
|
+
eip.associate :instance => spec.location['instance_id']
|
48
|
+
end
|
49
|
+
new_resource.instance_id eip.instance_id
|
50
|
+
rescue => e
|
51
|
+
Chef::Application.fatal!("Error Associating EIP: #{e}")
|
52
|
+
end
|
53
|
+
new_resource.save
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
action :disassociate do
|
58
|
+
converge_by "Disassociating EIP Address #{new_resource.name} in #{new_resource.region_name}" do
|
59
|
+
begin
|
60
|
+
if existing_ip != nil
|
61
|
+
existing_ip.disassociate
|
62
|
+
new_resource.instance_id nil
|
63
|
+
new_resource.save
|
64
|
+
else
|
65
|
+
Chef::Log.warn("No EIP found to disassociate")
|
66
|
+
end
|
67
|
+
rescue => e
|
68
|
+
Chef::Application.fatal!("Error Disassociating EIP: #{e}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def existing_ip
|
74
|
+
new_resource.hydrate
|
75
|
+
@existing_ip ||= new_resource.public_ip == nil ? nil : begin
|
76
|
+
eip = ec2.elastic_ips[new_resource.public_ip]
|
77
|
+
eip
|
78
|
+
rescue => e
|
79
|
+
Chef::Application.fatal!("Error looking for EIP Address: #{e}")
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
end
|
@@ -176,7 +176,7 @@ class Chef::Provider::AwsKeyPair < Chef::Provider::AwsProvider
|
|
176
176
|
@current_resource = Chef::Resource::AwsKeyPair.new(new_resource.name, run_context)
|
177
177
|
|
178
178
|
current_key_pair = ec2.key_pairs[new_resource.name]
|
179
|
-
if current_key_pair
|
179
|
+
if current_key_pair && current_key_pair.exists?
|
180
180
|
@current_fingerprint = current_key_pair ? current_key_pair.fingerprint : nil
|
181
181
|
else
|
182
182
|
current_resource.action :delete
|
@@ -7,6 +7,20 @@ class Chef::Provider::AwsS3Bucket < Chef::Provider::AwsProvider
|
|
7
7
|
converge_by "Creating new S3 bucket #{fqn}" do
|
8
8
|
bucket = s3.buckets.create(fqn)
|
9
9
|
bucket.tags['Name'] = new_resource.name
|
10
|
+
if new_resource.enable_website_hosting
|
11
|
+
bucket.website_configuration = AWS::S3::WebsiteConfiguration.new(
|
12
|
+
new_resource.website_options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
elsif requires_modification?
|
16
|
+
converge_by "Modifying S3 Bucket #{fqn}" do
|
17
|
+
if existing_bucket.website_configuration == nil && new_resource.enable_website_hosting ||
|
18
|
+
existing_bucket.website_configuration != nil && new_resource.enable_website_hosting
|
19
|
+
existing_bucket.website_configuration = AWS::S3::WebsiteConfiguration.new(
|
20
|
+
new_resource.website_options)
|
21
|
+
else
|
22
|
+
existing_bucket.remove_website_configuration
|
23
|
+
end
|
10
24
|
end
|
11
25
|
end
|
12
26
|
|
@@ -29,13 +43,29 @@ class Chef::Provider::AwsS3Bucket < Chef::Provider::AwsProvider
|
|
29
43
|
@existing_bucket ||= s3.buckets[fqn] if s3.buckets[fqn].exists?
|
30
44
|
end
|
31
45
|
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
def requires_modification?
|
47
|
+
if existing_bucket.website_configuration == nil
|
48
|
+
new_resource.enable_website_hosting
|
49
|
+
else
|
50
|
+
!new_resource.enable_website_hosting ||
|
51
|
+
!compare_website_configuration
|
52
|
+
end
|
35
53
|
end
|
36
54
|
|
37
|
-
def
|
38
|
-
|
55
|
+
def compare_website_configuration
|
56
|
+
# This is incomplete, routing rules have many optional values, so its
|
57
|
+
# possible aws will put in default values for those which won't be in
|
58
|
+
# the requested config.
|
59
|
+
new_web_config = new_resource.website_options
|
60
|
+
current_web_config = existing_bucket.website_configuration.to_hash
|
61
|
+
|
62
|
+
current_web_config[:index_document] == new_web_config.fetch(:index_document, {}) &&
|
63
|
+
current_web_config[:error_document] == new_web_config.fetch(:error_document, {}) &&
|
64
|
+
current_web_config[:routing_rules] == new_web_config.fetch(:routing_rules, [])
|
39
65
|
end
|
40
66
|
|
67
|
+
# Fully qualified bucket name (i.e resource_region unless otherwise specified)
|
68
|
+
def id
|
69
|
+
new_resource.bucket_name || new_resource.name
|
70
|
+
end
|
41
71
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'inifile'
|
2
2
|
require 'csv'
|
3
|
+
require 'chef/mixin/deep_merge'
|
3
4
|
|
4
5
|
class Chef
|
5
6
|
module Provisioning
|
6
7
|
module AWSDriver
|
7
|
-
# Reads in
|
8
|
+
# Reads in credential files in Amazon's download format and presents the credentials to you
|
8
9
|
class Credentials
|
9
10
|
def initialize
|
10
11
|
@credentials = {}
|
@@ -12,6 +13,7 @@ module AWSDriver
|
|
12
13
|
end
|
13
14
|
|
14
15
|
include Enumerable
|
16
|
+
include Chef::Mixin::DeepMerge
|
15
17
|
|
16
18
|
def default
|
17
19
|
if @credentials.size == 0
|
@@ -32,8 +34,16 @@ module AWSDriver
|
|
32
34
|
@credentials.each(&block)
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
36
|
-
|
37
|
+
def load_inis(config_ini_file, credentials_ini_file = nil)
|
38
|
+
@credentials = load_config_ini(config_ini_file)
|
39
|
+
@credentials = deep_merge!(@credentials,
|
40
|
+
load_credentials_ini(credentials_ini_file)
|
41
|
+
) if credentials_ini_file
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_config_ini(config_ini_file)
|
45
|
+
inifile = IniFile.load(File.expand_path(config_ini_file))
|
46
|
+
config = {}
|
37
47
|
if inifile
|
38
48
|
inifile.each_section do |section|
|
39
49
|
if section =~ /^\s*profile\s+(.+)$/ || section =~ /^\s*(default)\s*/
|
@@ -43,14 +53,27 @@ module AWSDriver
|
|
43
53
|
result
|
44
54
|
end
|
45
55
|
profile[:name] = profile_name
|
46
|
-
|
56
|
+
config[profile_name] = profile
|
47
57
|
end
|
48
58
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
59
|
+
end
|
60
|
+
config
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_credentials_ini(credentials_ini_file)
|
64
|
+
inifile = IniFile.load(File.expand_path(credentials_ini_file))
|
65
|
+
config = {}
|
66
|
+
if inifile
|
67
|
+
inifile.each_section do |section|
|
68
|
+
profile = inifile[section].inject({}) do |result, pair|
|
69
|
+
result[pair[0].to_sym] = pair[1]
|
70
|
+
result
|
71
|
+
end
|
72
|
+
profile[:name] = section
|
73
|
+
config[section] = profile
|
52
74
|
end
|
53
75
|
end
|
76
|
+
config
|
54
77
|
end
|
55
78
|
|
56
79
|
def load_csv(credentials_csv_file)
|
@@ -66,8 +89,13 @@ module AWSDriver
|
|
66
89
|
|
67
90
|
def load_default
|
68
91
|
config_file = ENV['AWS_CONFIG_FILE'] || File.expand_path('~/.aws/config')
|
92
|
+
credentials_file = ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
|
69
93
|
if File.file?(config_file)
|
70
|
-
|
94
|
+
if File.file?(credentials_file)
|
95
|
+
load_inis(config_file, credentials_file)
|
96
|
+
else
|
97
|
+
load_inis(config_file)
|
98
|
+
end
|
71
99
|
end
|
72
100
|
end
|
73
101
|
|
@@ -56,8 +56,6 @@ module AWSDriver
|
|
56
56
|
security_group_name = lb_options[:security_group_name] || 'default'
|
57
57
|
security_group_id = lb_options[:security_group_id]
|
58
58
|
|
59
|
-
# TODO confused: this variable doesn't appear to be used?
|
60
|
-
# default_sg = ec2.security_groups.filter('group-name', 'default')
|
61
59
|
security_group = if security_group_id.nil?
|
62
60
|
ec2.security_groups.filter('group-name', security_group_name).first
|
63
61
|
else
|
@@ -186,6 +184,18 @@ module AWSDriver
|
|
186
184
|
end
|
187
185
|
|
188
186
|
def destroy_load_balancer(action_handler, lb_spec, lb_options)
|
187
|
+
return if lb_spec == nil
|
188
|
+
|
189
|
+
actual_elb = load_balancer_for(lb_spec)
|
190
|
+
if actual_elb && actual_elb.exists?
|
191
|
+
# Remove ELB from AWS
|
192
|
+
action_handler.perform_action "Deleting EC2 ELB #{lb_spec.id}" do
|
193
|
+
actual_elb.delete
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Remove LB spec from databag
|
198
|
+
lb_spec.delete(action_handler)
|
189
199
|
end
|
190
200
|
|
191
201
|
# Image methods
|
@@ -201,7 +211,7 @@ module AWSDriver
|
|
201
211
|
# Machine methods
|
202
212
|
def allocate_machine(action_handler, machine_spec, machine_options)
|
203
213
|
actual_instance = instance_for(machine_spec)
|
204
|
-
if actual_instance == nil || !actual_instance.exists?
|
214
|
+
if actual_instance == nil || !actual_instance.exists? || actual_instance.status == :terminated
|
205
215
|
image_id = machine_options[:image_id] || default_ami_for_region(@region)
|
206
216
|
bootstrap_options = machine_options[:bootstrap_options] || {}
|
207
217
|
bootstrap_options[:image_id] = image_id
|
@@ -252,14 +262,14 @@ module AWSDriver
|
|
252
262
|
|
253
263
|
def destroy_machine(action_handler, machine_spec, machine_options)
|
254
264
|
instance = instance_for(machine_spec)
|
255
|
-
if instance
|
265
|
+
if instance && instance.exists?
|
256
266
|
# TODO do we need to wait_until(action_handler, machine_spec, instance) { instance.status != :shutting_down } ?
|
257
267
|
action_handler.perform_action "Terminate #{machine_spec.name} (#{machine_spec.location['instance_id']}) in #{@region} ..." do
|
258
268
|
instance.terminate
|
259
269
|
machine_spec.location = nil
|
260
270
|
end
|
261
271
|
else
|
262
|
-
Chef::Log.warn "
|
272
|
+
Chef::Log.warn "Instance #{machine_spec.location['instance_id']} doesn't exist for #{machine_spec.name}"
|
263
273
|
end
|
264
274
|
|
265
275
|
strategy = convergence_strategy_for(machine_spec, machine_options)
|
@@ -365,6 +375,8 @@ module AWSDriver
|
|
365
375
|
'ami-996706a3'
|
366
376
|
when 'eu-west-1'
|
367
377
|
'ami-4ab46b3d'
|
378
|
+
when 'eu-central-1'
|
379
|
+
'ami-7c3c0a61'
|
368
380
|
when 'sa-east-1'
|
369
381
|
'ami-6770d87a'
|
370
382
|
when 'us-east-1'
|
@@ -380,7 +392,7 @@ module AWSDriver
|
|
380
392
|
|
381
393
|
def create_ssh_transport(machine_spec, machine_options, instance)
|
382
394
|
ssh_options = ssh_options_for(machine_spec, machine_options, instance)
|
383
|
-
username = machine_spec.location['ssh_username'] || default_ssh_username
|
395
|
+
username = machine_spec.location['ssh_username'] || machine_options[:ssh_username] || default_ssh_username
|
384
396
|
if machine_options.has_key?(:ssh_username) && machine_options[:ssh_username] != machine_spec.location['ssh_username']
|
385
397
|
Chef::Log.warn("Server #{machine_spec.name} was created with SSH username #{machine_spec.location['ssh_username']} and machine_options specifies username #{machine_options[:ssh_username]}. Using #{machine_spec.location['ssh_username']}. Please edit the node and change the chef_provisioning.location.ssh_username attribute if you want to change it.")
|
386
398
|
end
|
@@ -444,6 +456,10 @@ module AWSDriver
|
|
444
456
|
end
|
445
457
|
|
446
458
|
def convergence_strategy_for(machine_spec, machine_options)
|
459
|
+
# Tell Ohai that this is an EC2 instance so that it runs the EC2 plugin
|
460
|
+
machine_options[:convergence_options] ||= {}
|
461
|
+
machine_options[:convergence_options][:ohai_hints] = { 'ec2' => ''}
|
462
|
+
|
447
463
|
# Defaults
|
448
464
|
if !machine_spec.location
|
449
465
|
return Chef::Provisioning::ConvergenceStrategy::NoConverge.new(machine_options[:convergence_options], config)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
resources = %w(sqs_queue sns_topic ebs_volume s3_bucket auto_scaling_group launch_config vpc security_group)
|
1
|
+
resources = %w(sqs_queue sns_topic ebs_volume s3_bucket auto_scaling_group launch_config vpc security_group eip_address)
|
2
2
|
|
3
3
|
resources.each do |r|
|
4
4
|
Chef::Log.debug "AWS driver loading resource: #{r}"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'chef/resource/aws_resource'
|
2
|
+
require 'chef/provisioning/aws_driver'
|
3
|
+
require 'chef/provisioning/machine_spec'
|
4
|
+
|
5
|
+
class Chef::Resource::AwsEipAddress < Chef::Resource::AwsResource
|
6
|
+
self.resource_name = 'aws_eip_address'
|
7
|
+
self.databag_name = 'eip_addresses'
|
8
|
+
|
9
|
+
actions :create, :delete, :nothing, :associate, :disassociate
|
10
|
+
default_action :associate
|
11
|
+
|
12
|
+
stored_attribute :public_ip
|
13
|
+
stored_attribute :domain
|
14
|
+
|
15
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
16
|
+
attribute :associate_to_vpc, :kind_of => [TrueClass, FalseClass], :default => false
|
17
|
+
attribute :machine, :kind_of => String
|
18
|
+
attribute :instance_id, :kind_of => String
|
19
|
+
|
20
|
+
def initialize(*args)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def after_created
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
@@ -10,6 +10,8 @@ class Chef::Resource::AwsS3Bucket < Chef::Resource::AwsResource
|
|
10
10
|
|
11
11
|
attribute :name, :kind_of => String, :name_attribute => true
|
12
12
|
attribute :bucket_name, :kind_of => String
|
13
|
+
attribute :enable_website_hosting, :kind_of => [TrueClass, FalseClass], :default => false
|
14
|
+
attribute :website_options, :kind_of => Hash
|
13
15
|
|
14
16
|
def initialize(*args)
|
15
17
|
super
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'chef/dsl/recipe'
|
2
|
+
require 'chef/provisioning'
|
3
|
+
require 'chef/provisioning/aws_driver'
|
4
|
+
|
5
|
+
RSpec.configure do |rspec|
|
6
|
+
rspec.run_all_when_everything_filtered = true
|
7
|
+
rspec.filter_run :focus
|
8
|
+
rspec.order = 'random'
|
9
|
+
rspec.expect_with(:rspec) { |c| c.syntax = :expect }
|
10
|
+
rspec.before { allow($stdout).to receive(:write) }
|
11
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chef::Provisioning::AWSDriver::Credentials do
|
4
|
+
context 'loading config INI files' do
|
5
|
+
let(:personal_credentials) do
|
6
|
+
{ region: 'us-west-2',
|
7
|
+
aws_access_key_id: 'AKIAPERSONALKEY',
|
8
|
+
aws_secret_access_key: 'personalsecretaccesskey',
|
9
|
+
name: 'personal'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:work_iam_credentials) do
|
14
|
+
{ region: 'us-east-1',
|
15
|
+
aws_access_key_id: 'AKIAWORKIAMKEY',
|
16
|
+
aws_secret_access_key: 'workiamsecretaccesskey',
|
17
|
+
name: 'work_iam'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:config_ini_file) do
|
22
|
+
@config ||= begin
|
23
|
+
ini = Tempfile.new('config_ini')
|
24
|
+
ini.write(
|
25
|
+
['[profile personal]',
|
26
|
+
'region = us-west-2',
|
27
|
+
'[profile work_iam]',
|
28
|
+
'region = us-east-1'
|
29
|
+
].join("\n")
|
30
|
+
)
|
31
|
+
ini.rewind
|
32
|
+
ini
|
33
|
+
end
|
34
|
+
@config
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:credential_ini_file) do
|
38
|
+
@creds ||= begin
|
39
|
+
ini = Tempfile.new('credential_ini')
|
40
|
+
ini.write(
|
41
|
+
['[personal]',
|
42
|
+
'aws_access_key_id = AKIAPERSONALKEY',
|
43
|
+
'aws_secret_access_key = personalsecretaccesskey',
|
44
|
+
'[work_iam]',
|
45
|
+
'aws_access_key_id = AKIAWORKIAMKEY',
|
46
|
+
'aws_secret_access_key = workiamsecretaccesskey'
|
47
|
+
].join("\n")
|
48
|
+
)
|
49
|
+
ini.rewind
|
50
|
+
ini
|
51
|
+
end
|
52
|
+
@creds
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:unified_config_ini_file) do
|
56
|
+
@ini ||= begin
|
57
|
+
ini = Tempfile.new('unified_config_ini')
|
58
|
+
ini.write(
|
59
|
+
['[profile personal]',
|
60
|
+
'region = us-west-2',
|
61
|
+
'aws_access_key_id = AKIAPERSONALKEY',
|
62
|
+
'aws_secret_access_key = personalsecretaccesskey',
|
63
|
+
'[profile work_iam]',
|
64
|
+
'region = us-east-1',
|
65
|
+
'aws_access_key_id = AKIAWORKIAMKEY',
|
66
|
+
'aws_secret_access_key = workiamsecretaccesskey'
|
67
|
+
].join("\n")
|
68
|
+
)
|
69
|
+
ini.rewind
|
70
|
+
ini
|
71
|
+
end
|
72
|
+
@ini
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'unified config ini file' do
|
76
|
+
%w(work_iam personal).each do |profile|
|
77
|
+
it "loads the '#{profile}' profile from a unified config file" do
|
78
|
+
ENV['AWS_DEFAULT_PROFILE'] = profile
|
79
|
+
ENV['AWS_CREDENTIAL_FILE'] = nil
|
80
|
+
ENV['AWS_CONFIG_FILE'] = unified_config_ini_file.path
|
81
|
+
allow(File)
|
82
|
+
.to receive(:file?)
|
83
|
+
.with(File.expand_path('~/.aws/credentials'))
|
84
|
+
.and_return(false)
|
85
|
+
allow(File)
|
86
|
+
.to receive(:file?)
|
87
|
+
.with(File.expand_path(unified_config_ini_file.path))
|
88
|
+
.and_return(true)
|
89
|
+
|
90
|
+
expect(described_class.new.default)
|
91
|
+
.to eq(send("#{profile}_credentials"))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'separate config and credential ini files' do
|
97
|
+
%w(work_iam personal).each do |profile|
|
98
|
+
it "loads the '#{profile}' profile from a separate config files" do
|
99
|
+
ENV['AWS_DEFAULT_PROFILE'] = profile
|
100
|
+
ENV['AWS_CREDENTIAL_FILE'] = credential_ini_file.path
|
101
|
+
ENV['AWS_CONFIG_FILE'] = config_ini_file.path
|
102
|
+
|
103
|
+
expect(described_class.new.default)
|
104
|
+
.to eq(send("#{profile}_credentials"))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Ewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 11.16.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 11.16.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chef-provisioning
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - '>='
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: pry
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - '>='
|
@@ -93,6 +107,7 @@ files:
|
|
93
107
|
- Rakefile
|
94
108
|
- lib/chef/provider/aws_auto_scaling_group.rb
|
95
109
|
- lib/chef/provider/aws_ebs_volume.rb
|
110
|
+
- lib/chef/provider/aws_eip_address.rb
|
96
111
|
- lib/chef/provider/aws_key_pair.rb
|
97
112
|
- lib/chef/provider/aws_launch_config.rb
|
98
113
|
- lib/chef/provider/aws_provider.rb
|
@@ -112,6 +127,7 @@ files:
|
|
112
127
|
- lib/chef/resource/aws_auto_scaling_group.rb
|
113
128
|
- lib/chef/resource/aws_ebs_mount.rb
|
114
129
|
- lib/chef/resource/aws_ebs_volume.rb
|
130
|
+
- lib/chef/resource/aws_eip_address.rb
|
115
131
|
- lib/chef/resource/aws_key_pair.rb
|
116
132
|
- lib/chef/resource/aws_launch_config.rb
|
117
133
|
- lib/chef/resource/aws_resource.rb
|
@@ -120,6 +136,8 @@ files:
|
|
120
136
|
- lib/chef/resource/aws_sns_topic.rb
|
121
137
|
- lib/chef/resource/aws_sqs_queue.rb
|
122
138
|
- lib/chef/resource/aws_vpc.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/unit/aws_driver/credentials_spec.rb
|
123
141
|
homepage: https://github.com/opscode/chef-provisioning-aws
|
124
142
|
licenses: []
|
125
143
|
metadata: {}
|