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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ AWS_QUEUE_URL=<queue-url> AWS_FUNCTION_NAME=<function-name> AWS_REGION=<aws-regi

> Note that if both environment variables are set and arguments are passed as flags, the arguments take precedence.

Additionally, when you have set `AWS_ENVIRONMENT` we will automatically append this behind your `<function-name>`.

## SQS message format

The SQS message body should be in JSON format. The content of the message is passed to your Lambda function as its first argument. For example:
Expand All @@ -58,4 +60,4 @@ exports.handler = function (data, context) {
console.log("Email:", data.email);
context.done();
}
```
```
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var debug = require('debug')('sqs-to-lambda');
var region = argv.region;
var queueUrl = argv.queueUrl;
var functionName = argv.functionName;
var environment = argv.environment;

if(typeof queueUrl === 'object') {
queueUrl = queueUrl[0];
Expand All @@ -18,6 +19,9 @@ if(typeof region === 'object') {
if(typeof functionName === 'object') {
functionName = functionName[0];
}
if(environment) {
functionName += '-' + environment;
}

if (!region || !queueUrl || !functionName) {
console.log('Usage: sqs-to-lambda --queue-url <queue-url> --function-name <function-name> --region <region>');
Expand Down