Skip to content
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

Adds support for AWS Temporary Credentials #46

Merged
merged 1 commit into from
Nov 3, 2015
Merged
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: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ Default value: `null`
If you wish to use a specific AWS credentials profile you can specify it here, otherwise it will use the environment default.
You can also specify it with the environment variable `AWS_PROFILE`

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

If you wish to assume a specific role from an EC2 instance you can specify it here, otherwise it will use the environment default.

##### options.accessKeyId
Type: `String`
Default value: `null`
Expand Down Expand Up @@ -517,5 +523,3 @@ Adding more warnings for various failure cases

### 0.10.0
* Making NPM a regular dependency to resolve [#20](https://github.com/Tim-B/grunt-aws-lambda/issues/20) - [pull request by timdp](https://github.com/Tim-B/grunt-aws-lambda/pull/27)


10 changes: 10 additions & 0 deletions tasks/lambda_deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function (grunt) {

var options = this.options({
profile: null,
roleArn: null,
accessKeyId: null,
secretAccessKey: null,
credentialsJSON: null,
Expand All @@ -37,6 +38,15 @@ module.exports = function (grunt) {
AWS.config.credentials = credentials;
}

if (options.roleArn !== null) {
AWS.config.credentials = new AWS.EC2MetadataCredentials({
httpOptions: { timeout: 5000 } // 5 second timeout
});
AWS.config.credentials = new AWS.TemporaryCredentials({
RoleArn: options.roleArn
});
}

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