|
1 |
| -# serverless-aws-lambda-dynamic-trigger |
| 1 | +## Modules |
| 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. |
| 66 | +3. Register the ARNs as triggers with the configured lambda function or functions. |
| 67 | + |
| 68 | +Please note that currently you can only use the plugin with sns, sqs or kinesis triggers (events). |
| 69 | + |
| 70 | +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 |
| 72 | +- arn:aws:sns:eu-west-2:123456654321:topic1 |
| 73 | +- arn:aws:sns:eu-west-2:123456654321:topic2 |
| 74 | +- arn:aws:sns:eu-west-2:123456654321:topic3 |
| 75 | +while on *prod* foo lambda function is triggered by |
| 76 | +- arn:aws:sns:eu-west-2:123456654321:topic1 |
| 77 | +- arn:aws:sns:eu-west-2:123456654321:topic2 |
| 78 | +This way we can switch features on and off on different stages. |
| 79 | + |
| 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 |
| 83 | +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 | + |
| 87 | +The config parameters: |
| 88 | +- region: the region of the Systems Manager -> Parameter Store |
| 89 | +- functions: |
| 90 | + - name: The name of the function |
| 91 | + |
| 92 | +plugins: |
| 93 | + - @kakkuk/serverless-aws-lambda-dynamic-trigger |
| 94 | +custom: |
| 95 | + dynamicTrigger: |
| 96 | + region: "eu-west-2" // !!! Optional !!! It'll fall back to AWS_DEFAULT_REGION if it's not set |
| 97 | + 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 |
0 commit comments