Skip to content

Enabled to set session token for hardcoded AWS credentials #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ Default value: `null`

If you wish to use hardcoded AWS credentials you should specify the Secret Access Key here

##### options.sessionToken
Type: `String`
Default value: `null`

If you wish to use hardcoded AWS credentials and you need to specify session token. This is an optional AWS session token. Usually you will need just `accessKeyId` and `secretAccessKey`.

##### options.credentialsJSON
Type: `String`
Default value: `null`
Expand Down Expand Up @@ -643,4 +649,4 @@ Adding more warnings for various failure cases

* Added support for Node 4.3 runtime callback function - [pull request by bobhigs](https://github.com/Tim-B/grunt-aws-lambda/pull/76)
* Added VPC support - [pull request by beeva-arturomartinez](https://github.com/Tim-B/grunt-aws-lambda/pull/71)
* Added local proxy support - [pull request by alekstr](https://github.com/Tim-B/grunt-aws-lambda/pull/66)
* Added local proxy support - [pull request by alekstr](https://github.com/Tim-B/grunt-aws-lambda/pull/66)
12 changes: 11 additions & 1 deletion utils/deploy_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ deployTask.getHandler = function (grunt) {
RoleArn: null,
accessKeyId: null,
secretAccessKey: null,
sessionToken: null,
credentialsJSON: null,
region: 'us-east-1',
timeout: null,
Expand Down Expand Up @@ -64,7 +65,16 @@ deployTask.getHandler = function (grunt) {
}

if (options.accessKeyId !== null && options.secretAccessKey !== null) {
AWS.config.update({accessKeyId: options.accessKeyId, secretAccessKey: options.secretAccessKey});
var sdkCredentials = {
accessKeyId: options.accessKeyId,
secretAccessKey: options.secretAccessKey
};

if (options.sessionToken !== null) {
sdkCredentials.sessionToken = options.sessionToken;
}

AWS.config.update(sdkCredentials);
}

if (options.credentialsJSON !== null) {
Expand Down