removed aws api keys handling

This commit is contained in:
Eslam A. Hefnawy 2016-06-21 18:21:53 +02:00
parent 2c4c559dfd
commit 1a1ec2103f
2 changed files with 6 additions and 20 deletions

View File

@ -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;

View File

@ -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 = {