diff --git a/README.md b/README.md index 52910b1f..1d129761 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ $ node-lambda deploy --help -f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env") -b, --vpcSubnets [] VPC Subnet ID(s, comma separated list) for your Lambda Function, when using this, the below param is also required -g, --vpcSecurityGroups [] VPC Security Group ID(s, comma separated list) for your Lambda Function, when using this, the above param is also required + -Q, --deadLetterConfigTargetArn [] Lambda DLQ resource -A, --packageDirectory [] Local package directory -S, --eventSourceFile [event_sources.json] Path to file holding event source mapping variables (e.g. "event_sources.json") -x, --excludeGlobs [] Add a space separated list of file(type)s to ignore (e.g. "*.json .env") diff --git a/bin/node-lambda b/bin/node-lambda index e4c2437b..a2a7388d 100755 --- a/bin/node-lambda +++ b/bin/node-lambda @@ -31,6 +31,7 @@ var AWS_PUBLISH = process.env.AWS_PUBLISH || false; var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || ''; var AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || ''; var AWS_VPC_SECURITY_GROUPS = process.env.AWS_VPC_SECURITY_GROUPS || ''; +var AWS_DLQ_TARGET_ARN = process.env.AWS_DLQ_TARGET_ARN || ''; var EVENT_FILE = process.env.EVENT_FILE || 'event.json'; var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY; var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json'; @@ -60,6 +61,8 @@ program .option('-b, --vpcSubnets [' + AWS_VPC_SUBNETS + ']', 'Lambda Function VPC Subnets', AWS_VPC_SUBNETS) .option('-g, --vpcSecurityGroups [' + AWS_VPC_SECURITY_GROUPS + ']', 'Lambda VPC Security Group', AWS_VPC_SECURITY_GROUPS) + .option('-Q, --deadLetterConfigTargetArn [' + AWS_DLQ_TARGET_ARN + ']', 'Lambda DLQ resource', + AWS_DLQ_TARGET_ARN) .option('-A, --packageDirectory [' + PACKAGE_DIRECTORY + ']', 'Local Package Directory', PACKAGE_DIRECTORY) .option('-f, --configFile [' + CONFIG_FILE + ']', 'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE) diff --git a/lib/.env.example b/lib/.env.example index 65305a4f..5165a68c 100644 --- a/lib/.env.example +++ b/lib/.env.example @@ -13,5 +13,6 @@ AWS_DESCRIPTION= AWS_RUNTIME=nodejs6.10 AWS_VPC_SUBNETS= AWS_VPC_SECURITY_GROUPS= +AWS_DLQ_TARGET_ARN= EXCLUDE_GLOBS="event.json" PACKAGE_DIRECTORY=build diff --git a/lib/main.js b/lib/main.js index e0ee1194..5c70d275 100644 --- a/lib/main.js +++ b/lib/main.js @@ -112,6 +112,9 @@ Lambda.prototype._params = function (program, buffer) { }, Environment: { Variables: {} + }, + DeadLetterConfig: { + TargetArn: '' } }; if (program.lambdaVersion) { @@ -130,6 +133,11 @@ Lambda.prototype._params = function (program, buffer) { Variables: config } } + if (program.deadLetterConfigTargetArn) { + params.DeadLetterConfig = { + TargetArn: program.deadLetterConfigTargetArn + }; + } return params; }; @@ -328,7 +336,8 @@ Lambda.prototype._uploadExisting = function (lambda, params, cb) { 'Timeout': params.Timeout, 'Runtime': params.Runtime, 'VpcConfig': params.VpcConfig, - 'Environment': params.Environment + 'Environment': params.Environment, + 'DeadLetterConfig': params.DeadLetterConfig }, function (err, data) { return cb(err, data); }); diff --git a/test/main.js b/test/main.js index e2938569..68824ba6 100644 --- a/test/main.js +++ b/test/main.js @@ -22,6 +22,7 @@ var originalProgram = { timeout: 3, description: '', runtime: 'nodejs6.10', + deadLetterConfigTargetArn: '', region: 'us-east-1,us-west-2,eu-west-1', eventFile: 'event.json', contextFile: 'context.json',