Skip to content

failsafe-engineering/serverless-aws-lambda-dynamic-trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modules

index

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.
  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).

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

  • 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
  • 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 triger sets needs to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:

Members

Package @kakkuk/serverless-aws-lambda-dynamic-trigger

Serverless plugin registers a set of events stored in the AWS Parameter Store.

index

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.
  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).

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

  • 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
  • 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 triger sets needs to ne stored in the Parameter Store of the Systems Manager (SSM) and it should look somewhat like this:

Example

*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:
- functions:
  - name: The name of the function
  - ssmPath: Path to ssm which stores the triggers for the function. The value of the parameter should be a list of aws arns.

Example

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}"

Package @kakkuk/serverless-aws-lambda-dynamic-trigger

Serverless plugin registers a set of events stored in the AWS Parameter Store.

Kind: global variable

About

Dynamic triggers for was lambda functions

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •