Fix #3979. CLI option aws-profile overrides AWS_PROFILE env var

This commit is contained in:
mpuittinen 2017-07-24 10:30:30 +03:00
parent 6e6f0d56b7
commit 4e96ea77c4

View File

@ -195,21 +195,19 @@ class AwsProvider {
const result = {};
const stageUpper = this.getStage() ? this.getStage().toUpperCase() : null;
let profile;
if (this.options['aws-profile']) {
profile = this.options['aws-profile'];
} else if (this.serverless.service.provider.profile) {
profile = this.serverless.service.provider.profile;
}
// add specified credentials, overriding with more specific declarations
impl.addCredentials(result, this.serverless.service.provider.credentials); // config creds
impl.addProfileCredentials(result, profile);
if (this.serverless.service.provider.profile) {
// config profile
impl.addProfileCredentials(result, this.serverless.service.provider.profile);
}
impl.addEnvironmentCredentials(result, 'AWS'); // creds for all stages
impl.addEnvironmentProfile(result, 'AWS');
impl.addEnvironmentCredentials(result, `AWS_${stageUpper}`); // stage specific creds
impl.addEnvironmentProfile(result, `AWS_${stageUpper}`);
if (this.options['aws-profile']) {
impl.addProfileCredentials(result, this.options['aws-profile']); // CLI option profile
}
result.region = this.getRegion();
const deploymentBucketObject = this.serverless.service.provider.deploymentBucketObject;