Skip to content

Commit

Permalink
Adding option for AWS session token
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Galdao committed Oct 22, 2021
1 parent 80c6cc7 commit 9fb7f6d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const optionDefinitions = [
{ name: 'inputCredentials', alias: 'i', type: Boolean, description: 'Input the AWS access key id and secret access key via {underline stdin}', group: 'credentials' },
{ name: 'accessKeyId', description: 'AWS access key id ({bold not recommended:} use "aws configure" or "--inputCredentials" instead)', group: 'credentials' },
{ name: 'secretAccessKey', description: 'AWS secret access key ({bold not recommended:} use "aws configure" or "--inputCredentials" instead)', group: 'credentials' },
{ name: 'sessionToken', description: 'AWS session token', group: 'credentials' },
// Other
{ name: 'negate', alias: 'n', type: Boolean, defaultValue: false, description: 'Negates the result of the pattern matching\n(I.e.: to find messages NOT containing a text)' },
{ name: 'timeout', alias: 't', type: Number, defaultValue: 60, typeLabel: '{underline seconds}', description: 'Timeout for the whole operation to complete.\nThe message visibility timeout will be calculated based on this value as well and the elapsed time to ensure that messages become visible again as soon as possible.' },
Expand Down
3 changes: 3 additions & 0 deletions src/sqs-grep.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ class SqsGrep {
if (options.secretAccessKey) {
opts.secretAccessKey = options.secretAccessKey;
}
if (options.sessionToken) {
opts.sessionToken = options.sessionToken;
}
if (options.endpointUrl) {
opts.endpoint = new AWS.Endpoint(options.endpointUrl);
}
Expand Down
5 changes: 5 additions & 0 deletions test/test-sqs-grep.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ describe('SqsGrep', function () {
const opts = SqsGrep._getAwsOptions(options);
assert.equal(opts.secretAccessKey, 'SECRET');
});
it('should set the sessionToken', async function () {
const options = parse(['--sessionToken', 'TOKEN']);
const opts = SqsGrep._getAwsOptions(options);
assert.equal(opts.sessionToken, 'TOKEN');
});
it('should set the endpointUrl', async function () {
const options = parse(['--endpointUrl', 'http://localhost:5000']);
const opts = SqsGrep._getAwsOptions(options);
Expand Down

0 comments on commit 9fb7f6d

Please sign in to comment.