Skip to content

explicitly set aws credentials from CDO config#7903

Merged
laurelfan merged 1 commit into
stagingfrom
explicitly_set_aws_cr
Apr 15, 2016
Merged

explicitly set aws credentials from CDO config#7903
laurelfan merged 1 commit into
stagingfrom
explicitly_set_aws_cr

Conversation

@laurelfan

@laurelfan laurelfan commented Apr 15, 2016

Copy link
Copy Markdown
Contributor

I was encountering this error when trying to do rake adhoc:start

> bundle exec rake adhoc:start 
RAILS_ENV=adhoc RACK_ENV=adhoc bundle exec ./update_certs adhoc-pair-programming.cdn-code.org
bundle --without development production adhoc staging test levelbuilder integration --quiet --jobs 2
RAILS_ENV=adhoc RACK_ENV=adhoc bundle exec berks package /var/folders/_k/pygg7wg52jj3yl3k3ywsc53c0000gn/T/berks20160415-81844-1x3xbno
rake aborted!
Aws::Errors::MissingCredentialsError: unable to sign request without credentials set
/Users/laurel/code-dot-org/lib/cdo/aws/cloud_formation.rb:121:in `block (2 levels) in update_cookbooks'

The problem is that the cloudformation stuff was happening inside a block that resets the environment, so the AWS_ environment variables set in deployment.rb were being reset. Change to explicitly getting the config from CDO instead of using the environment.

Comment thread deployment.rb
# Set AWS SDK environment variables from provided config.
ENV['AWS_ACCESS_KEY_ID'] ||= config['aws_access_key'] || config['s3_access_key_id']
ENV['AWS_SECRET_ACCESS_KEY'] ||= config['aws_secret_key'] || config['s3_secret_access_key']
# Set AWS SDK environment variables from provided config and standardize on aws_* attributres

@laurelfan laurelfan Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this here so that I wouldn't have to repeat the aws_access_key || s3_access_key_id thing in the cloud_formation.rb code. I feel a bit weird about writing the config object, but we seem to do that all over the place here anyway...

@wjordan

wjordan commented Apr 15, 2016

Copy link
Copy Markdown
Contributor

thanks for digging into this! Yeah, this should work for now. I'll look at refactoring setting these credentials explicitly like this to use Aws.config in the future in an initializer somewhere so we can be consistent wherever we use the aws sdk in our codebase.

@laurelfan laurelfan merged commit 36987f9 into staging Apr 15, 2016
@laurelfan laurelfan deleted the explicitly_set_aws_cr branch May 25, 2016 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants