diff --git a/lib/plugins/aws/index.js b/lib/plugins/aws/index.js index 2dedadb72..92394cf28 100644 --- a/lib/plugins/aws/index.js +++ b/lib/plugins/aws/index.js @@ -80,27 +80,12 @@ class SDK { } const profile = process.env[`${prefix}_PROFILE`] - || this.serverless.service.getVariables(stage).profile - || this.serverless.config.aws_profile; + || this.serverless.service.getVariables(stage).profile; if (profile) { credentials.profile = profile; } else { - credentials.accessKeyId = process.env[`${prefix}_ACCESS_KEY_ID`] - || this.serverless.service.getVariables(stage).accessKeyId - || this.serverless.config.aws_accessKeyId; - - credentials.secretAccessKey = process.env[`${prefix}_SECRET_ACCESS_KEY`] - || this.serverless.service.getVariables(stage).secretAccessKey - || this.serverless.config.aws_secretAccessKey; - - credentials.sessionToken = process.env[`${prefix}_SESSION_TOKEN`] - || this.serverless.service.getVariables(stage).sessionToken - || this.serverless.config.aws_sessionToken; - } - - if (!credentials.profile && (!credentials.accessKeyId || !credentials.secretAccessKey)) { - throw new this.serverless.classes.Error('Please provide a profile or access key pair'); + throw new this.serverless.classes.Error('Please provide an aws profile'); } return credentials; diff --git a/lib/plugins/aws/tests/index.js b/lib/plugins/aws/tests/index.js index e2d53148a..c7143b3bb 100644 --- a/lib/plugins/aws/tests/index.js +++ b/lib/plugins/aws/tests/index.js @@ -87,9 +87,10 @@ describe('AWS SDK', () => { describe('#getCredentials()', () => { it('should get credentials', () => { const serverless = new Serverless(); - serverless.config.aws_profile = 'default'; serverless.service.environment = { - vars: {}, + vars: { + profile: 'default', + }, stages: { dev: { vars: {}, @@ -128,7 +129,7 @@ describe('AWS SDK', () => { expect(credentials.profile).to.deep.equal('default'); }); - it('should throw error if credentials not provided', () => { + it('should throw error if profile not set', () => { const serverless = new Serverless(); const awsSdk = new AwsSdk(serverless); serverless.service.environment = {