capistrano-ec2 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d49bd03dc7164feac8b3857fc6aefd82c845aa0
4
- data.tar.gz: 96ae1cca4d6c6330dc9e5469f7e204d8ccd07e83
3
+ metadata.gz: a565dadc8f1f7ffba685488bf8a804a4633a2a18
4
+ data.tar.gz: be80c99f0570af72dd553571b079fdd08fe3fa72
5
5
  SHA512:
6
- metadata.gz: '0292e3718d4f1afd8e2c3e57fa59bd66f4d55f542f5d215d43f33d9d3bdfc37ceffe33bf75485426fc9846d3835156577205d780162d8d8618f1049620f9b2bd'
7
- data.tar.gz: c5e233c40c7324e753e02dad5d862231f1006dcca57c1c7b0734ff1ac6b561333fd8c93021326a44b17dc6649a01b764582d68096dc61579fc70ef7ba5048cc7
6
+ metadata.gz: ff5558324541bf6832b335cb1f90fe189943bc91bd6b963f646ce6afad1e80e0be9744868d30e34351de31ac0b50739c07f0aea8258a6442739fc6536fe3b99f
7
+ data.tar.gz: 6484ea5bc858ff7d4adee69a0bef087c851f2bba5412280c9feba2af0dfa9ec156c2764df20ca252a3da44bcfa5e197447993fc12579face04c9881e09c9c978
@@ -3,15 +3,10 @@ require 'fog/aws'
3
3
  module Capistrano
4
4
  class Configuration
5
5
  def for_each_ec2_server(ec2_env:, ec2_role:, &block)
6
- ec2 = Fog::Compute.new \
7
- provider: 'AWS',
8
- region: fetch(:region),
9
- use_iam_profile: fetch(:use_iam_profile, false)
10
-
11
- filters = {
12
- "tag:ec2_env" => ec2_env,
13
- "tag:role" => ec2_role,
14
- 'instance-state-name': 'running'
6
+ filters = {
7
+ 'tag:ec2_env' => ec2_env,
8
+ 'tag:role' => ec2_role,
9
+ 'instance-state-name': 'running'
15
10
  }
16
11
 
17
12
  ec2.servers.all(filters).map.with_index do |ec2_server, index|
@@ -20,6 +15,45 @@ module Capistrano
20
15
  yield ec2_server, index
21
16
  end
22
17
  end
18
+
19
+ private
20
+
21
+ def ec2
22
+ @ec2 ||= Fog::Compute.new(fog_arguments)
23
+ end
24
+
25
+ def fog_arguments
26
+ default_options = {
27
+ provider: 'AWS',
28
+ region: region,
29
+ }
30
+
31
+ if use_iam_profile
32
+ default_options.merge(iam_profile_options)
33
+ else
34
+ default_options.merge(access_key_options)
35
+ end
36
+ end
37
+
38
+ def region
39
+ fetch(:region)
40
+ end
41
+
42
+ def use_iam_profile
43
+ fetch(:use_iam_profile, false)
44
+ end
45
+
46
+ def iam_profile_options
47
+ { use_iam_profile: true }
48
+ end
49
+
50
+ def access_key_options
51
+ {
52
+ aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
53
+ aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
54
+ aws_session_token: ENV['AWS_SESSION_TOKEN'],
55
+ }
56
+ end
23
57
  end
24
58
 
25
59
  module DSL
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Ec2
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Vries