diff --git a/lib/plugins/aws/provider/awsProvider.js b/lib/plugins/aws/provider/awsProvider.js index c7354fb43..fffecdef6 100644 --- a/lib/plugins/aws/provider/awsProvider.js +++ b/lib/plugins/aws/provider/awsProvider.js @@ -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;