Skip to content

Commit 6d80b18

Browse files
author
Sean Dawson
committed
feat: allow CloudFormation overrides
- We keep having to add new options to the config when someone needs to use an option in the CloudFormation template we haven't mapped yet - This should future proof the plugin to allow users to just pass whatever they need through to override the generated template - Eventually we could also deprecate and remove some of the other options that could just be overrides - Fixes #213
1 parent 9cafac0 commit 6d80b18

9 files changed

+370
-10720
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ node_modules
1212
.history
1313

1414
# tsc output
15-
dist
15+
dist
16+
17+
#misc
18+
yarn-error.log
19+
*.tgz

README.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ boilerplate to add a Queue and a Dead Letter Queue between the Lambda and the
1515
SNS topic. This plugin allows you to define an sns subscriber with a `batchSize`
1616
and a `maxRetryCount` as simply as subscribing directly to the sns topic.
1717

18-
![Plugin Architecture](./plant-uml-files/plugin-arch.png?raw=true "Plugin Architecture")
19-
2018
# Table of Contents
2119

2220
- [Install](#install)
@@ -60,6 +58,25 @@ functions:
6058
- dog
6159
- cat
6260

61+
# Overrides for generated CloudFormation templates
62+
# Mirrors the CloudFormation docs but uses camel case instead of title case
63+
#
64+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
65+
mainQueueOverride:
66+
maximumMessageSize: 1024
67+
...
68+
deadLetterQueueOverride:
69+
maximumMessageSize: 1024
70+
...
71+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html
72+
eventSourceMappingOverride:
73+
sourceAccessConfigurations:
74+
- Type: SASL_SCRAM_256_AUTH
75+
URI: arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName
76+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html
77+
subscriptionOverride:
78+
region: ap-southeast-2
79+
6380
resources:
6481
Resources:
6582
Topic:
@@ -70,3 +87,26 @@ resources:
7087
plugins:
7188
- "@agiledigital/serverless-sns-sqs-lambda"
7289
```
90+
91+
### CloudFormation Overrides
92+
93+
If you would like to override a part of the CloudFormation template
94+
that is generated by this plugin, you can pass raw CloudFormation
95+
to the override config options outlined above.
96+
97+
The configuration must be provided with camel case keys,
98+
but apart from that, you can use the CloudFormation config
99+
as specified by AWS.
100+
101+
For example, if you wanted to override the maximumMessageSize for the main queue
102+
you could find the "MaximumMessageSize" config option in the [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html)
103+
make the key camel case ("maximumMessageSize") and pass it into the override section:
104+
105+
```yaml
106+
events:
107+
- snsSqs:
108+
name: Example
109+
...
110+
mainQueueOverride:
111+
maximumMessageSize: 1024
112+
```

example-service/serverless.yml

+16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ functions:
2828
- dog
2929
- cat
3030

31+
# Overrides for generated CloudFormation templates
32+
# Mirrors the CloudFormation docs but uses camel case instead of title case
33+
#
34+
#
35+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
36+
mainQueueOverride:
37+
maximumMessageSize: 1024
38+
deadLetterQueueOverride:
39+
delaySeconds: 120
40+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html
41+
eventSourceMappingOverride:
42+
enabled: false
43+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html
44+
subscriptionOverride:
45+
rawMessageDelivery: true
46+
3147
resources:
3248
Resources:
3349
Topic:

0 commit comments

Comments
 (0)