Skip to content

Commit 50002db

Browse files
authored
Merge pull request #4 from failsafe-engineering/chore/tweak-readme-and-keywords
Patch: Tweak readme and keywords
2 parents 7e5f6cd + 09a2b39 commit 50002db

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
# serverless-aws-lambda-dynamic-trigger
22

33
The plugin can register triggers (events) for a lambda function dynamically at the time of the deployment.
4-
1. It fetches the value of a parameter form the Parameter Store. The value must be a list ARNs separated by commas.
4+
The usual static trigger (event) definitions can be completely omitted.
5+
The original idea is to make the same lambda function triggered by different events on different environments (stages).
6+
This way we can even do some basic **feature switching**.
7+
8+
## How it works
9+
The plugin when the host code gets deployed...
10+
1. Fetches the value of a defined parameter from the Parameter Store. The value must be a list ARNs separated by commas. (If there is only one trigger it's just a single ARN)
511
2. Parses the individual ARNs and pulls out the name of the aws service.
6-
3. Register the ARNs as triggers with the configured lambda function or functions.
12+
3. Registers the ARNs as triggers with the configured lambda function or functions.
713

814
Please note that you can only use the plugin with **sns**, **sqs** or **kinesis** triggers.
915

10-
The original idea is to make the same lambda function triggered by different events on different environments (stages).
1116
Like on **dev** foo lambda function is triggered by
1217
- arn:aws:sns:eu-west-2:123456654321:topic1
1318
- arn:aws:sns:eu-west-2:123456654321:topic2
1419
- arn:aws:sns:eu-west-2:123456654321:topic3
15-
while on **prod** foo lambda function is triggered by
20+
21+
While on **prod** foo lambda function is triggered by
1622
- arn:aws:sns:eu-west-2:123456654321:topic1
1723
- arn:aws:sns:eu-west-2:123456654321:topic2
24+
1825
This way we can switch features on and off on different stages.
1926

20-
The dynamic trigger sets need to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:
27+
The dynamic trigger sets need to be stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:
2128

2229
- **Name**: /dev/dynamic-trigger
2330
- **Value**: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2,arn:aws:sns:eu-west-2:123456654321:topic3
@@ -34,6 +41,7 @@ or
3441
- **ssmPath**: {string} It's actually the name of the parameter in the Parameter Store
3542

3643
## Example
44+
The configuration in the serverless.yml:
3745
```yml
3846
plugins:
3947
- @kakkuk/serverless-aws-lambda-dynamic-trigger
@@ -42,7 +50,18 @@ custom:
4250
region: "eu-west-2" // !!! Optional !!! It'll fall back to AWS_DEFAULT_REGION if it's not set
4351
functions:
4452
- name: "handler1"
45-
ssmPath: "/prod/tigger-set1"
53+
ssmPath: "/${opt:stage}/trigger-set1" // This is the dynamic part :)
4654
- name: "handler2"
47-
ssmPath: "/prod/tigger-set2"
55+
ssmPath: "/${opt:stage}/trigger-set2" // This is the dynamic part :)
56+
57+
// Further down in the serverless.yml
58+
59+
handler1:
60+
handler: src/handler1
61+
name: ${self:service}-handler1
62+
// No events section needed
63+
handler2:
64+
handler: src/handler1
65+
name: ${self:service}-handler2
66+
// No events section needed
4867
```

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
"aws",
2222
"lambda",
2323
"dynamic",
24-
"trigger"
24+
"trigger",
25+
"feature switching",
26+
"feature toggling",
27+
"sns",
28+
"sqs",
29+
"kinesis"
2530
],
2631
"author": "Failsafe Engineering <[email protected]>",
2732
"license": "ISC",

0 commit comments

Comments
 (0)