SeanRoy / lambda-maven-plugin

A maven plugin to facilitate lambda deployments as part of your maven build/dev process

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: way to delete orphaned triggers

coopernurse opened this issue · comments

First off, thanks for writing this plugin, it's pretty handy.

I like the inlined trigger support, but it looks like if you rename a trigger the old ones remain (at least CloudWatch Events do - didn't try SNS).

It would be nice if there was some way to mark a trigger "deleted" which would be applied the next time the plugin is run. This would eliminate the need to go and remove an orphaned trigger manually.

One possibility might be to add an optional "deleted" attribute to the triggers JSON, (default=false) which if true would remove the trigger. For example:

"triggers": [
                        { "integration": "CloudWatch Events - Schedule",
                          "ruleName": "every-minute",
                          "deleted": true },
                        { "integration": "CloudWatch Events - Schedule",
                          "ruleName": "an-active-trigger",
                          "ruleDescription": "runs lambda every minute",
                          "scheduleExpression": "rate(1 minutes)" }
                ]

every-minute would be deleted if it exists, while an-active-trigger would be created/updated.

This would enable a workflow where you could mark a trigger deleted for some amount of time until you're sure the lambda has been deployed across all environments and the orphaned trigger removed. Then the deleted trigger rule could be removed from the triggers array entirely.

I've fixed this for CloudWatch Events in v2.2.1. If you rename a trigger or remove one from your triggers list, it will automatically be removed from AWS, assuming your function is the only target of the event rule.

I will add similar trigger cleanup code in subsequent revisions. I'll keep this issue open until I complete them.

Fixed in 2.2.7