diff --git a/README.md b/README.md index 16aa4c4..fa3e960 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ AWS_QUEUE_URL= AWS_FUNCTION_NAME= AWS_REGION= 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 ``. + ## 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: @@ -58,4 +60,4 @@ exports.handler = function (data, context) { console.log("Email:", data.email); context.done(); } -``` +``` \ No newline at end of file diff --git a/index.js b/index.js index 73f9bff..213972c 100755 --- a/index.js +++ b/index.js @@ -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]; @@ -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 --function-name --region ');