Skip to content

Patch: Remove auto doc generation #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 27 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,48 @@
## Modules
# serverless-aws-lambda-dynamic-trigger

<dl>
<dt><a href="#index.module_js">js</a></dt>
<dd><p>The plugin can register triggers (events) for a lambda function dynamically. At deployment time</p>
<ol>
<li>It fetches the value of a parameter in the Parameters. The value must be a list ARNs sepearted by comma.</li>
<li>Parses the individual ARNs.</li>
<li>Register the ARNs as triggers with the configured lambda function or functions.</li>
</ol>
<p>Please note that currently you can only use the plugin with sns, sqs or kinesis triggers (events).</p>
<p>The original idea is to make the same lambda function triggered by different events on different environments (stages).
Like on <em>dev</em> foo lambda function is triggered by</p>
<ul>
<li>arn:aws:sns:eu-west-2:123456654321:topic1</li>
<li>arn:aws:sns:eu-west-2:123456654321:topic2</li>
<li>arn:aws:sns:eu-west-2:123456654321:topic3
while on <em>prod</em> foo lambda function is triggered by</li>
<li>arn:aws:sns:eu-west-2:123456654321:topic1</li>
<li>arn:aws:sns:eu-west-2:123456654321:topic2
This way we can switch features on and off on different stages.</li>
</ul>
<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:
Name: /dev/dynamic-trigger
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
or
Name: /prod/dynamic-trigger
Value: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2</p>
<p>The config parameters:</p>
<ul>
<li>region: the region of the Systems Manager -&gt; Parameter Store</li>
<li>functions:<ul>
<li>name: The name of the function</li>
</ul>
</li>
</ul>
<p>plugins:</p>
<ul>
<li>@kakkuk/serverless-aws-lambda-dynamic-trigger
custom:
dynamicTrigger:
region: &quot;eu-west-2&quot; // !!! Optional !!! It&#39;ll fall back to AWS_DEFAULT_REGION if it&#39;s not set
functions:<ul>
<li>name: &quot;handler&quot;
ssmPath: &quot;{/path/to/triggers}&quot;</li>
</ul>
</li>
</ul>
</dd>
</dl>

## Members

<dl>
<dt><a href="#Package @kakkuk/serverless-aws-lambda-dynamic-trigger">Package @kakkuk/serverless-aws-lambda-dynamic-trigger</a></dt>
<dd><p>Serverless plugin registers a set of events stored in the AWS Parameter Store.</p>
</dd>
</dl>

<a name="index.module_js"></a>

## js
The plugin can register triggers (events) for a lambda function dynamically. At deployment time
1. It fetches the value of a parameter in the Parameters. The value must be a list ARNs sepearted by comma.
2. Parses the individual ARNs.
The plugin can register triggers (events) for a lambda function dynamically at the time of the deployment.
1. It fetches the value of a parameter form the Parameter Store. The value must be a list ARNs separated by commas.
2. Parses the individual ARNs and pulls out the name of the aws service.
3. Register the ARNs as triggers with the configured lambda function or functions.

Please note that currently you can only use the plugin with sns, sqs or kinesis triggers (events).
Please note that you can only use the plugin with **sns**, **sqs** or **kinesis** triggers.

The original idea is to make the same lambda function triggered by different events on different environments (stages).
Like on *dev* foo lambda function is triggered by
Like on **dev** foo lambda function is triggered by
- arn:aws:sns:eu-west-2:123456654321:topic1
- arn:aws:sns:eu-west-2:123456654321:topic2
- arn:aws:sns:eu-west-2:123456654321:topic3
while on *prod* foo lambda function is triggered by
while on **prod** foo lambda function is triggered by
- arn:aws:sns:eu-west-2:123456654321:topic1
- arn:aws:sns:eu-west-2:123456654321:topic2
This way we can switch features on and off on different stages.

The dynamic trigger sets needs to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:
Name: /dev/dynamic-trigger
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
The dynamic trigger sets need to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:

- **Name**: /dev/dynamic-trigger
- **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

or
Name: /prod/dynamic-trigger
Value: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2

The config parameters:
- region: the region of the Systems Manager -> Parameter Store
- functions:
- name: The name of the function
- **Name**: /prod/dynamic-trigger
- **Value**: arn:aws:sns:eu-west-2:123456654321:topic1,arn:aws:sns:eu-west-2:123456654321:topic2

## The config parameters:
- **region**: {string} the region of the Systems Manager -> Parameter Store
- **functions**: {Array<name: string, ssmPath: string>}
- **name**: {string} The name of the function
- **ssmPath**: {string} It's actually the name of the parameter in the Parameter Store

## Example
```yml
plugins:
- @kakkuk/serverless-aws-lambda-dynamic-trigger
custom:
dynamicTrigger:
region: "eu-west-2" // !!! Optional !!! It'll fall back to AWS_DEFAULT_REGION if it's not set
functions:
- name: "handler"
ssmPath: "{/path/to/triggers}"

<a name="Package @kakkuk/serverless-aws-lambda-dynamic-trigger"></a>

## Package @kakkuk/serverless-aws-lambda-dynamic-trigger
Serverless plugin registers a set of events stored in the AWS Parameter Store.

**Kind**: global variable
- name: "handler1"
ssmPath: "/prod/tigger-set1"
- name: "handler2"
ssmPath: "/prod/tigger-set2"
```
Loading