capify-ec2 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.4.7 (May 16, 2013)
2
+
3
+ Features:
4
+
5
+ - Added the ability to load AWS credentials from the Fog configuration file, rather than from the 'ec2.yml' file. Refer to the Fog documentation for details on specifying AWS credentials.
6
+ - Improved error handling when no AWS credentials are found by any supported method.
7
+
1
8
  ## 1.4.6 (May 15, 2013)
2
9
 
3
10
  Features:
data/lib/capify-ec2.rb CHANGED
@@ -33,11 +33,20 @@ class CapifyEc2
33
33
  regions = determine_regions()
34
34
 
35
35
  @instances = []
36
+
36
37
  regions.each do |region|
37
- Fog::Compute.new(:provider => 'AWS',
38
- :aws_access_key_id => aws_access_key_id,
39
- :aws_secret_access_key => aws_secret_access_key,
40
- :region => region).servers.each do |server|
38
+ begin
39
+ servers = Fog::Compute.new( :provider => 'AWS',
40
+ :aws_access_key_id => aws_access_key_id,
41
+ :aws_secret_access_key => aws_secret_access_key,
42
+ :region => region
43
+ ).servers
44
+ rescue => e
45
+ puts "[Capify-EC2] Unable to connect to AWS: #{e}.".red.bold
46
+ exit 1
47
+ end
48
+
49
+ servers.each do |server|
41
50
  @instances << server if server.ready?
42
51
  end
43
52
  end
@@ -48,11 +57,11 @@ class CapifyEc2
48
57
  end
49
58
 
50
59
  def aws_access_key_id
51
- @ec2_config[:aws_access_key_id] || ENV['AWS_ACCESS_KEY_ID']
60
+ @ec2_config[:aws_access_key_id] || Fog.credentials[:aws_access_key_id] || ENV['AWS_ACCESS_KEY_ID'] || raise("Missing AWS Access Key ID")
52
61
  end
53
62
 
54
63
  def aws_secret_access_key
55
- @ec2_config[:aws_secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY']
64
+ @ec2_config[:aws_secret_access_key] || Fog.credentials[:aws_secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY'] || raise("Missing AWS Secret Access Key")
56
65
  end
57
66
 
58
67
  def display_instances
@@ -1,6 +1,6 @@
1
1
  module Capify
2
2
  module Ec2
3
- VERSION = "1.4.6"
3
+ VERSION = "1.4.7"
4
4
  end
5
5
  end
6
6
 
data/readme.md CHANGED
@@ -31,7 +31,7 @@ require "capify-ec2/capistrano"
31
31
 
32
32
  #### Configuration
33
33
 
34
- Note: ':aws_access_key_id', ':aws_secret_access_key', and ':region' are required. Other settings are optional.
34
+ Note: ':aws_access_key_id' and ':aws_secret_access_key' are required, unless you provide them via the two alternative methods detailed below. ':region' is also required. Other settings are optional.
35
35
 
36
36
  * :project_tag
37
37
 
@@ -58,10 +58,24 @@ Note: ':aws_access_key_id', ':aws_secret_access_key', and ':region' are required
58
58
 
59
59
  Use this option to change which EC2 instance tag Capify-EC2 uses to determine instance options. Defaults to 'Options' if ommited.
60
60
 
61
- ##### Via Environment Variables
61
+ ##### AWS Credentials
62
+
63
+ ###### Via YML Configuration
64
+
65
+ By default, Capify-EC2 will attempt to use the credentials found in your 'ec2.yml' configuration as detailed above.
66
+
67
+ ###### Via Fog Configuration
68
+
69
+ If you wish, you can have Capify-EC2 use the AWS credentials found in your Fog configuration, instead of instead of specifying ':aws_access_key_id' and ':aws_secret_access_key' in the YML configuration file. Refer to the Fog documentation for details on specifying AWS credentials.
70
+
71
+ ###### Via Environment Variables
62
72
 
63
73
  If you wish, you can define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables, instead of specifying ':aws_access_key_id' and ':aws_secret_access_key' in the YML configuration file.
64
74
 
75
+ ###### Ordering
76
+
77
+ Capify-EC2 will attempt to load your AWS credentials first from the 'ec2.yml' configuration file, then from your Fog configuration file, and finally from environment variables. It will display an error if no credentials are found by any of these methods.
78
+
65
79
 
66
80
 
67
81
  #### EC2 Tags
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capify-ec2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 6
10
- version: 1.4.6
9
+ - 7
10
+ version: 1.4.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Noah Cantor
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2013-05-15 00:00:00 Z
21
+ date: 2013-05-16 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: fog