|
1 |
| -## Modules |
| 1 | +# serverless-aws-lambda-dynamic-trigger |
2 | 2 |
|
3 |
| -<dl> |
4 |
| -<dt><a href="#index.module_js">js</a></dt> |
5 |
| -<dd><p>The plugin can register triggers (events) for a lambda function dynamically. At deployment time</p> |
6 |
| -<ol> |
7 |
| -<li>It fetches the value of a parameter in the Parameters. The value must be a list ARNs sepearted by comma.</li> |
8 |
| -<li>Parses the individual ARNs.</li> |
9 |
| -<li>Register the ARNs as triggers with the configured lambda function or functions.</li> |
10 |
| -</ol> |
11 |
| -<p>Please note that currently you can only use the plugin with sns, sqs or kinesis triggers (events).</p> |
12 |
| -<p>The original idea is to make the same lambda function triggered by different events on different environments (stages). |
13 |
| -Like on <em>dev</em> foo lambda function is triggered by</p> |
14 |
| -<ul> |
15 |
| -<li>arn:aws:sns:eu-west-2:123456654321:topic1</li> |
16 |
| -<li>arn:aws:sns:eu-west-2:123456654321:topic2</li> |
17 |
| -<li>arn:aws:sns:eu-west-2:123456654321:topic3 |
18 |
| -while on <em>prod</em> foo lambda function is triggered by</li> |
19 |
| -<li>arn:aws:sns:eu-west-2:123456654321:topic1</li> |
20 |
| -<li>arn:aws:sns:eu-west-2:123456654321:topic2 |
21 |
| -This way we can switch features on and off on different stages.</li> |
22 |
| -</ul> |
23 |
| -<p>The dynamic trigger sets needs to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this: |
24 |
| -Name: /dev/dynamic-trigger |
25 |
| -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 |
26 |
| -or |
27 |
| -Name: /prod/dynamic-trigger |
28 |
| -Value: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2</p> |
29 |
| -<p>The config parameters:</p> |
30 |
| -<ul> |
31 |
| -<li>region: the region of the Systems Manager -> Parameter Store</li> |
32 |
| -<li>functions:<ul> |
33 |
| -<li>name: The name of the function</li> |
34 |
| -</ul> |
35 |
| -</li> |
36 |
| -</ul> |
37 |
| -<p>plugins:</p> |
38 |
| -<ul> |
39 |
| -<li>@kakkuk/serverless-aws-lambda-dynamic-trigger |
40 |
| -custom: |
41 |
| - dynamicTrigger: |
42 |
| -region: "eu-west-2" // !!! Optional !!! It'll fall back to AWS_DEFAULT_REGION if it's not set |
43 |
| -functions:<ul> |
44 |
| -<li>name: "handler" |
45 |
| -ssmPath: "{/path/to/triggers}"</li> |
46 |
| -</ul> |
47 |
| -</li> |
48 |
| -</ul> |
49 |
| -</dd> |
50 |
| -</dl> |
51 |
| - |
52 |
| -## Members |
53 |
| - |
54 |
| -<dl> |
55 |
| -<dt><a href="#Package @kakkuk/serverless-aws-lambda-dynamic-trigger">Package @kakkuk/serverless-aws-lambda-dynamic-trigger</a></dt> |
56 |
| -<dd><p>Serverless plugin registers a set of events stored in the AWS Parameter Store.</p> |
57 |
| -</dd> |
58 |
| -</dl> |
59 |
| - |
60 |
| -<a name="index.module_js"></a> |
61 |
| - |
62 |
| -## js |
63 |
| -The plugin can register triggers (events) for a lambda function dynamically. At deployment time |
64 |
| -1. It fetches the value of a parameter in the Parameters. The value must be a list ARNs sepearted by comma. |
65 |
| -2. Parses the individual ARNs. |
| 3 | +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. |
| 5 | +2. Parses the individual ARNs and pulls out the name of the aws service. |
66 | 6 | 3. Register the ARNs as triggers with the configured lambda function or functions.
|
67 | 7 |
|
68 |
| -Please note that currently you can only use the plugin with sns, sqs or kinesis triggers (events). |
| 8 | +Please note that you can only use the plugin with **sns**, **sqs** or **kinesis** triggers. |
69 | 9 |
|
70 | 10 | The original idea is to make the same lambda function triggered by different events on different environments (stages).
|
71 |
| -Like on *dev* foo lambda function is triggered by |
| 11 | +Like on **dev** foo lambda function is triggered by |
72 | 12 | - arn:aws:sns:eu-west-2:123456654321:topic1
|
73 | 13 | - arn:aws:sns:eu-west-2:123456654321:topic2
|
74 | 14 | - arn:aws:sns:eu-west-2:123456654321:topic3
|
75 |
| -while on *prod* foo lambda function is triggered by |
| 15 | +while on **prod** foo lambda function is triggered by |
76 | 16 | - arn:aws:sns:eu-west-2:123456654321:topic1
|
77 | 17 | - arn:aws:sns:eu-west-2:123456654321:topic2
|
78 | 18 | This way we can switch features on and off on different stages.
|
79 | 19 |
|
80 |
| -The dynamic trigger sets needs to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this: |
81 |
| -Name: /dev/dynamic-trigger |
82 |
| -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 |
| 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: |
| 21 | + |
| 22 | +- **Name**: /dev/dynamic-trigger |
| 23 | +- **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 |
| 24 | + |
83 | 25 | or
|
84 |
| -Name: /prod/dynamic-trigger |
85 |
| -Value: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2 |
86 | 26 |
|
87 |
| -The config parameters: |
88 |
| -- region: the region of the Systems Manager -> Parameter Store |
89 |
| -- functions: |
90 |
| - - name: The name of the function |
| 27 | +- **Name**: /prod/dynamic-trigger |
| 28 | +- **Value**: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2 |
| 29 | + |
| 30 | +## The config parameters: |
| 31 | +- **region**: {string} the region of the Systems Manager -> Parameter Store |
| 32 | +- **functions**: {Array<name: string, ssmPath: string>} |
| 33 | + - **name**: {string} The name of the function |
| 34 | + - **ssmPath**: {string} It's actually the name of the parameter in the Parameter Store |
91 | 35 |
|
| 36 | +## Example |
| 37 | +```yml |
92 | 38 | plugins:
|
93 | 39 | - @kakkuk/serverless-aws-lambda-dynamic-trigger
|
94 | 40 | custom:
|
95 | 41 | dynamicTrigger:
|
96 | 42 | region: "eu-west-2" // !!! Optional !!! It'll fall back to AWS_DEFAULT_REGION if it's not set
|
97 | 43 | functions:
|
98 |
| - - name: "handler" |
99 |
| - ssmPath: "{/path/to/triggers}" |
100 |
| - |
101 |
| -<a name="Package @kakkuk/serverless-aws-lambda-dynamic-trigger"></a> |
102 |
| - |
103 |
| -## Package @kakkuk/serverless-aws-lambda-dynamic-trigger |
104 |
| -Serverless plugin registers a set of events stored in the AWS Parameter Store. |
105 |
| - |
106 |
| -**Kind**: global variable |
| 44 | + - name: "handler1" |
| 45 | + ssmPath: "/prod/tigger-set1" |
| 46 | + - name: "handler2" |
| 47 | + ssmPath: "/prod/tigger-set2" |
| 48 | +``` |
0 commit comments