Skip to content
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,18 @@ Allows you to publish a new version when passing in a string for `lambda_params`
#### `region = 'us-east-1'`

Set your AWS region.

#### `credentials`

Allow to override the AWS object. For example, this could be useful is you need to provide credentials from alternate source.

For example:
```js
AWS.config.loadFromPath('../aws.json');
var awsCredentials = AWS.config.credentials;

var opts = {
credentials: awsCredentials;
};
```
The `credentials` parameter will take precedence over the region one.
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var DEFAULT_PARAMS = {
Runtime: 'nodejs4.3'
};

var makeWarning = function(message) {
return gutil.log(gutil.colors.red(message));
};

var makeErr = function(message) {
return new gutil.PluginError('gulp-awslambda', message);
Expand Down Expand Up @@ -67,12 +70,24 @@ module.exports = function(params, opts) {

gutil.log('Uploading Lambda function "' + functionName + '"...');

if (opts.profile && opts.config) {
return cb(makeWarning('Option "credentials" will take precedence over option "region"'));
}

if (opts.profile !== null) {
AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: opts.profile });
}

AWS.config.update({ region: opts.region });

if (opts.credentials !== null) {
if (opts.credentials.constructor.name === 'Credentials') {
AWS.config.credentials = opts.credentials;
} else {
return cb(makeErr('Option `credentials` is not an instance of Credentials'));
}
}

var lambda = new AWS.Lambda();
var stream = this;

Expand Down