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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fe36e5e375099bfc35214d89869ebfd01a56d31
4
- data.tar.gz: 62408a6905eee21aa2b00963bf1b7839e0bd0255
3
+ metadata.gz: e06f594fcaf7833e8604356594161d4f73aee045
4
+ data.tar.gz: 3be47666d4d53efdfe61b265aaa330e5dea76fd9
5
5
  SHA512:
6
- metadata.gz: 0fb1282a4e7a02d2a6e0e2fe6f07acb8e2c09bdd2132cb8e158205db96e6ce4740fb2f86f5d203a4c5427715dbc5a1d93e6958ccdd8f0be1358d7b9b9601108b
7
- data.tar.gz: 9494fe769e3b3a4a923768d439e5eea4ca49e549ae3223544dfd269e00aed17639e0dfcdf4d022bdd965f42afe037aef1830cf13e2c407462817058fcbb3a1e7
6
+ metadata.gz: 50e43aaa626fdfe146e81b2b3e46871a81ed0349f7f8a7e41218c0dcb62bec57db132480df8f56e51a05f79ffa23abd9cfffcbd6e7647177d425a8eede41477d
7
+ data.tar.gz: a40123b77824b0790e2d138916e17a68eb9e9aab363319b04a587832b80883f9a444174208ee6925fec189eec36aa07c6cf8a3bd413ae60e14ae412a2cf64c49
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem 'net-ssh', '~> 2.0'
@@ -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, role_session_name: 'aerosol'
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
@@ -51,8 +51,18 @@ namespace :aerosol do
51
51
 
52
52
  namespace :env do
53
53
  Aerosol.envs.values.each do |env|
54
- desc "Run all of the deploys for #{env.name} in parallel"
55
- multitask env.name => env.deploy.map { |dep| "aerosol:#{dep.name}:all" }
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
 
@@ -1,5 +1,5 @@
1
1
  # Copyright Swipely, Inc. All rights reserved.
2
2
 
3
3
  module Aerosol
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
@@ -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
@@ -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.2.0
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-07-27 00:00:00.000000000 Z
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: