Skip to content

Commit

Permalink
Fix AWS creds handling
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Dec 4, 2019
1 parent f2a41bf commit 3561687
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/plugins/aws/invokeLocal/index.js
Expand Up @@ -128,13 +128,17 @@ class AwsInvokeLocal {
NODE_PATH: '/var/runtime:/var/task:/var/runtime/node_modules',
};

const credentialEnvVars = this.provider.cachedCredentials
? {
AWS_ACCESS_KEY_ID: this.provider.cachedCredentials.accessKeyId,
AWS_SECRET_ACCESS_KEY: this.provider.cachedCredentials.secretAccessKey,
AWS_SESSION_TOKEN: this.provider.cachedCredentials.sessionToken,
}
: {};
const { cachedCredentials } = this.provider;
const credentialEnvVars = {};
if (cachedCredentials.accessKeyId) {
credentialEnvVars.AWS_ACCESS_KEY_ID = cachedCredentials.accessKeyId;
}
if (cachedCredentials.secretAccessKey) {
credentialEnvVars.AWS_SECRET_ACCESS_KEY = cachedCredentials.secretAccessKey;
}
if (cachedCredentials.sessionToken) {
credentialEnvVars.AWS_SESSION_TOKEN = cachedCredentials.sessionToken;
}

// profile override from config
const profileOverride = this.provider.getProfile();
Expand Down

2 comments on commit 3561687

@radzserg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently gets

  TypeError: Cannot read property 'accessKeyId' of null
      at AwsInvokeLocal.loadEnvVars (/Users/radzserg/.nvm/versions/node/v10.16.3/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:133:27)
  From previous event:

why did you remove ?: check

const cachedCredentials = this.provider.cachedCredentials || {};

@medikoo
Copy link
Contributor Author

@medikoo medikoo commented on 3561687 Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radzserg being fixed here: #7054 Patch will be published in minutes

Please sign in to comment.