mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
removed aws api keys handling
This commit is contained in:
parent
2c4c559dfd
commit
1a1ec2103f
@ -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;
|
||||
|
||||
@ -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 = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user