Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ElasticBeanstalk optional session token #1218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/dpl/providers/elasticbeanstalk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Elasticbeanstalk < Provider

opt '--access_key_id ID', 'AWS Access Key ID', required: true, secret: true
opt '--secret_access_key KEY', 'AWS Secret Key', required: true, secret: true
opt '--session_token TOKEN', 'AWS Session Token', required: false, secret: true
opt '--region REGION', 'AWS Region the Elastic Beanstalk app is running in', default: 'us-east-1'
opt '--app NAME', 'Elastic Beanstalk application name', default: :repo_name
opt '--env NAME', 'Elastic Beanstalk environment name to be updated.'
Expand All @@ -43,14 +44,15 @@ class Elasticbeanstalk < Provider
opt '--debug', internal: true

msgs login: 'Using Access Key: %{access_key_id}',
login_token: 'Using Access Key: %{access_key_id}, Session Token: %{session_token}',
zip_add: 'Adding %s'

msgs clean_description: 'Removed non-printable characters from the version description'

attr_reader :started, :object, :version

def login
info :login
info(session_token ? :login_token : :login)
end

def setup
Expand Down Expand Up @@ -173,7 +175,7 @@ def environment
end

def credentials
Aws::Credentials.new(access_key_id, secret_access_key)
Aws::Credentials.new(access_key_id, secret_access_key, session_token)
end

def s3
Expand Down
14 changes: 14 additions & 0 deletions spec/dpl/providers/elasticbeanstalk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@
it { is_expected.to have_run '[info] Using Access Key: ac******************' }
end

describe 'with ~/.aws/credentials', run: false do
let(:args) { |e| %w(--env env --bucket_name bucket) }

file '~/.aws/credentials', <<-str.sub(/^\s*/, '')
[default]
aws_access_key_id=access_key_id
aws_secret_access_key=secret_access_key
aws_session_token=token
str

before { subject.run }
it { should have_run '[info] Using Access Key: ac******************, Session Token: t*******************' }
end

describe 'with ~/.aws/config', run: false do
let(:args) { |_e| %w[--access_key_id id --secret_access_key secret] }

Expand Down