serverless-plugin-lambda-dead-letter
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,2 +1,11 @@ | ||
# 1.2.0 (2017-01-30) | ||
## Features | ||
* Dead Letter Queue properties #12 | ||
## Meta | ||
* [Git Hub Mile Stone](https://github.com/gmetzker/serverless-plugin-lambda-dead-letter/milestone/2?closed=1) | ||
* [Comparison since last release](https://github.com/gmetzker/serverless-plugin-lambda-dead-letter/compare/v1.1.0...v1.2.0) | ||
# 1.1.0 (2017-01-29) | ||
@@ -3,0 +12,0 @@ |
{ | ||
"name": "serverless-plugin-lambda-dead-letter", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "serverless plugin that can configure a lambda with a dead letter queue or topic", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -52,3 +52,15 @@ # Serverless Plugin: Lambda DeadLetterConfig | ||
#### Create new dead-letter queue by name | ||
```YAML | ||
# 'functions' in serverless.yml | ||
functions: | ||
createUser: # Function name | ||
handler: handler.createUser # Reference to function 'createUser' in code | ||
deadLetter: | ||
sqs: createUser-dl-queue # New Queue with this name | ||
``` | ||
#### Create new dead-letter queue with properties | ||
```YAML | ||
@@ -62,3 +74,9 @@ # 'functions' in serverless.yml | ||
deadLetter: | ||
sqs: createUser-dl-queue | ||
sqs: # New Queue with these properties | ||
queueName: createUser-dl-queue | ||
delaySeconds: 60 | ||
maximumMessageSize: 2048 | ||
messageRetentionPeriod: 200000 | ||
receiveMessageWaitTimeSeconds: 15 | ||
visibilityTimeout: 300 | ||
``` | ||
@@ -65,0 +83,0 @@ |
@@ -265,12 +265,31 @@ 'use strict'; | ||
static capitalizeFirstLetter(string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
compileFunctionDeadLetterQueue(functionName, queueConfig) { | ||
if (typeof queueConfig !== 'string' && queueConfig !== null) { | ||
throw new Error(`Function property ${functionName}.deadLetter.sqs is an unexpected type. This must be a or string.`); | ||
const queueProps = { QueueName: '' }; | ||
if (typeof queueConfig === 'string' || queueConfig === null) { | ||
queueProps.QueueName = (queueConfig || '').trim(); | ||
} else if (typeof queueConfig === 'object') { | ||
Object.keys(queueConfig).forEach((key) => { | ||
if (Object.prototype.hasOwnProperty.call(queueConfig, key)) { | ||
queueProps[Plugin.capitalizeFirstLetter(key)] = queueConfig[key]; | ||
} | ||
}); | ||
} else { | ||
throw new Error(`Function property ${functionName}.deadLetter.sqs is an unexpected type. This must be an object or a string.`); | ||
} | ||
const queueName = (queueConfig || '').trim(); | ||
if (queueName.length < 1) { | ||
throw new Error(`Function property ${functionName}.deadLetter.sqs must contain one or more characters.`); | ||
if (queueProps.QueueName.length < 1) { | ||
throw new Error(`Function property ${functionName}.deadLetter.sqs queueName must contain one or more characters.`); | ||
} | ||
@@ -285,5 +304,3 @@ | ||
Type: 'AWS::SQS::Queue', | ||
Properties: { | ||
QueueName: queueName | ||
} | ||
Properties: queueProps | ||
}; | ||
@@ -290,0 +307,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21723
263
177