aerosol 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/aerosol/deploy.rb +3 -5
- data/lib/aerosol/env.rb +14 -0
- data/lib/aerosol/rake_task.rb +12 -2
- data/lib/aerosol/version.rb +1 -1
- data/spec/aerosol/deploy_spec.rb +34 -0
- data/spec/aerosol/env_spec.rb +34 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e06f594fcaf7833e8604356594161d4f73aee045
|
4
|
+
data.tar.gz: 3be47666d4d53efdfe61b265aaa330e5dea76fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50e43aaa626fdfe146e81b2b3e46871a81ed0349f7f8a7e41218c0dcb62bec57db132480df8f56e51a05f79ffa23abd9cfffcbd6e7647177d425a8eede41477d
|
7
|
+
data.tar.gz: a40123b77824b0790e2d138916e17a68eb9e9aab363319b04a587832b80883f9a444174208ee6925fec189eec36aa07c6cf8a3bd413ae60e14ae412a2cf64c49
|
data/Gemfile
CHANGED
data/lib/aerosol/deploy.rb
CHANGED
@@ -67,15 +67,13 @@ class Aerosol::Deploy
|
|
67
67
|
return if assume_role.nil?
|
68
68
|
Aws.config.update(
|
69
69
|
credentials: Aws::AssumeRoleCredentials.new(
|
70
|
-
role_arn: assume_role,
|
70
|
+
role_arn: assume_role,
|
71
|
+
role_session_name: "aerosol-#{name}",
|
72
|
+
client: Aerosol::AWS.sts
|
71
73
|
)
|
72
74
|
)
|
73
75
|
end
|
74
76
|
|
75
|
-
def sts
|
76
|
-
Aerosol::AWS.sts
|
77
|
-
end
|
78
|
-
|
79
77
|
def run_post_deploy
|
80
78
|
return if post_deploy_command.nil?
|
81
79
|
info "running post deploy: #{post_deploy_command}"
|
data/lib/aerosol/env.rb
CHANGED
@@ -2,5 +2,19 @@
|
|
2
2
|
class Aerosol::Env
|
3
3
|
include Dockly::Util::DSL
|
4
4
|
|
5
|
+
dsl_attribute :assume_role
|
5
6
|
dsl_class_attribute :deploy, Aerosol::Deploy, type: Array
|
7
|
+
|
8
|
+
default_value :assume_role, nil
|
9
|
+
|
10
|
+
def perform_role_assumption
|
11
|
+
return if assume_role.nil?
|
12
|
+
Aws.config.update(
|
13
|
+
credentials: Aws::AssumeRoleCredentials.new(
|
14
|
+
role_arn: assume_role,
|
15
|
+
role_session_name: "aerosol-#{name}",
|
16
|
+
client: Aerosol::AWS.sts
|
17
|
+
)
|
18
|
+
)
|
19
|
+
end
|
6
20
|
end
|
data/lib/aerosol/rake_task.rb
CHANGED
@@ -51,8 +51,18 @@ namespace :aerosol do
|
|
51
51
|
|
52
52
|
namespace :env do
|
53
53
|
Aerosol.envs.values.each do |env|
|
54
|
-
|
55
|
-
|
54
|
+
namespace env.name do
|
55
|
+
desc "Assumes a role if necessary for #{env.name}"
|
56
|
+
task :assume_role => 'aerosol:load' do |name|
|
57
|
+
Thread.current[:rake_task] = name
|
58
|
+
env.perform_role_assumption
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Run all of the deploys for #{env.name} in parallel"
|
62
|
+
multitask :run => env.deploy.map { |dep| "aerosol:#{dep.name}:all" }
|
63
|
+
end
|
64
|
+
|
65
|
+
task env.name => ["aerosol:env:#{env.name}:assume_role", "aerosol:env:#{env.name}:run"]
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
data/lib/aerosol/version.rb
CHANGED
data/spec/aerosol/deploy_spec.rb
CHANGED
@@ -20,6 +20,40 @@ describe Aerosol::Deploy do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe '#perform_role_assumption' do
|
24
|
+
context 'when assume_role is nil' do
|
25
|
+
it 'does not change the aws config' do
|
26
|
+
expect(Aws).to_not receive(:config)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when assume_role exists' do
|
31
|
+
let(:assume_role) { 'arn:aws:sts::123456789123:role/role-aerosol' }
|
32
|
+
|
33
|
+
before do
|
34
|
+
Aerosol::AWS.sts.stub_responses(
|
35
|
+
:assume_role,
|
36
|
+
credentials: {
|
37
|
+
access_key_id: '123',
|
38
|
+
secret_access_key: '456',
|
39
|
+
session_token: '789',
|
40
|
+
expiration: Time.new + 60
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
after do
|
46
|
+
Aws.config.update(credentials: nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should set the Aws.config[:credentials]' do
|
50
|
+
subject.assume_role(assume_role)
|
51
|
+
expect { subject.perform_role_assumption }
|
52
|
+
.to change { Aws.config[:credentials] }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
23
57
|
describe '#run_post_deploy' do
|
24
58
|
context 'with no post_deploy_command' do
|
25
59
|
before do
|
data/spec/aerosol/env_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Aerosol::Env do
|
|
5
5
|
let(:name) { "unique_name_#{Time.now.to_i}".to_sym }
|
6
6
|
let!(:deploy) { Aerosol.deploy(name) { } }
|
7
7
|
|
8
|
-
|
9
8
|
it 'adds a deploy to the list of deploys' do
|
10
9
|
expect { subject.deploy(name) }
|
11
10
|
.to change { subject.deploy }
|
@@ -13,4 +12,38 @@ describe Aerosol::Env do
|
|
13
12
|
.to([deploy])
|
14
13
|
end
|
15
14
|
end
|
15
|
+
|
16
|
+
describe '#perform_role_assumption' do
|
17
|
+
context 'when assume_role is nil' do
|
18
|
+
it 'does not change the aws config' do
|
19
|
+
expect(Aws).to_not receive(:config)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when assume_role exists' do
|
24
|
+
let(:assume_role) { 'arn:aws:sts::123456789123:role/role-aerosol' }
|
25
|
+
|
26
|
+
before do
|
27
|
+
Aerosol::AWS.sts.stub_responses(
|
28
|
+
:assume_role,
|
29
|
+
credentials: {
|
30
|
+
access_key_id: '123',
|
31
|
+
secret_access_key: '456',
|
32
|
+
session_token: '789',
|
33
|
+
expiration: Time.new + 60
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
Aws.config.update(credentials: nil)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should set the Aws.config[:credentials]' do
|
43
|
+
subject.assume_role(assume_role)
|
44
|
+
expect { subject.perform_role_assumption }
|
45
|
+
.to change { Aws.config[:credentials] }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
16
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aerosol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swipely, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -293,3 +293,4 @@ test_files:
|
|
293
293
|
- spec/aerosol_spec.rb
|
294
294
|
- spec/spec_helper.rb
|
295
295
|
- spec/support/vcr.rb
|
296
|
+
has_rdoc:
|