serverless-sns-dlq 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +31 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -85,8 +85,6 @@ class ServerlessPlugin {
85
85
  // Add DLQ_QUEUE_URL to function environment
86
86
  if (!fnDef.environment) fnDef.environment = {};
87
87
  fnDef.environment.DLQ_QUEUE_URL = dlqUrl;
88
-
89
- this.logger.notice(`Added DLQ_QUEUE_URL for function ${fnName}: ${dlqUrl}`);
90
88
  };
91
89
 
92
90
  _configure = (accountId, template, fnName, fnDef, snsEvents) => {
@@ -135,16 +133,40 @@ class ServerlessPlugin {
135
133
  Queues: [{ Ref: queueId }],
136
134
  PolicyDocument: {
137
135
  Version: "2012-10-17",
138
- Statement: {
139
- Effect: "Allow",
140
- Principal: { Service: "sns.amazonaws.com" },
141
- Action: "sqs:SendMessage",
142
- Resource: { "Fn::GetAtt": [queueId, "Arn"] },
143
- Condition: { ArnEquals: { "aws:SourceArn": arns } },
136
+ Statement: [
137
+ {
138
+ Effect: "Allow",
139
+ Principal: { Service: "sns.amazonaws.com" },
140
+ Action: "sqs:SendMessage",
141
+ Resource: { "Fn::GetAtt": [queueId, "Arn"] },
142
+ Condition: { ArnEquals: { "aws:SourceArn": arns } },
143
+ },
144
+ {
145
+ Effect: "Allow",
146
+ Principal: { Service: "lambda.amazonaws.com" },
147
+ Action: "sqs:SendMessage",
148
+ Resource: { "Fn::GetAtt": [queueId, "Arn"] },
149
+ Condition: { ArnEquals: { "aws:SourceArn": { "Fn::GetAtt": [funcId, "Arn"] } } },
150
+ },
151
+ ],
152
+ },
153
+ },
154
+ };
155
+
156
+ // Add Lambda EventInvokeConfig for onFailure destination
157
+ const eventInvokeConfigId = pascalCase(`${fnName}EventInvokeConfig`);
158
+ template.Resources[eventInvokeConfigId] = {
159
+ Type: "AWS::Lambda::EventInvokeConfig",
160
+ Properties: {
161
+ FunctionName: { Ref: funcId },
162
+ Qualifier: "$LATEST",
163
+ DestinationConfig: {
164
+ OnFailure: {
165
+ Destination: { "Fn::GetAtt": [queueId, "Arn"] },
144
166
  },
145
167
  },
146
168
  },
147
- }
169
+ };
148
170
  }
149
171
  }
150
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-sns-dlq",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Automatically attach SNS redrive policy to DLQ for every handler function specified with SNS trigger",
5
5
  "main": "index.js",
6
6
  "author": "Randy Hermawan",