npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-existing-cloudwatch-rule

v1.0.1

Published

Allows functions to be triggered by pre-defined CloudWatch rules

Downloads

83

Readme

serverless-plugin-existing-cloudwatch-rule

npm version CircleCI Coverage Status

Allows an AWS Lambda function to be triggered by pre-configured CloudWatch event rules.

In contrast to the traditional schedule event that creates a new CloudWatch rule, the plugin assumes that an existing rule is already in place, and the Lambda function is specified as one of its targets. The plugin just adds necessary permissions to the Lambda function itself to complete the "link" between CloudWatch and Lambda.

Useful for projects that setup and scale infrastructure separately from code, e.g., deploy a Lambda function triggered by multiple timers or s3 events that are configured by scripts like Terraform, a separate CloudFormation template, or even a manually created infrastructure.

Also, can be useful for subscribing to an external (cross-account) rule.

Example serverless.yml:

plugins:
  - serverless-plugin-existing-cloudwatch-rule

functions:
  key-rotation-lambda: #1
    handler: src/key-rotation-lambda.handler
    events:
      - cloudWatchRule: key-rotation-timer
  counter-lambda: #2
    handler: src/counter-lambda.handler
    events:
      - cloudWatchRuleArn: 'arn:aws:events:us-east-1:160879880353:rule/my-project-MidnightSchedule-42UGHOTBBVIET'
  scalable-lambda: #3
    handler: src/scalable-lambda.handler
    events:
      - cloudWatchRule: ANY
  1. In the example, key-rotation-timer is assumed to be setup and pointing to key-rotation-lambda. The function key-rotation-lambda will be deployed on serverless deploy and, due to the plugin, with the necessary permissions to be invoked by key-rotation-timer. The timer will be shown on the AWS Lambda -> Triggers page as if it was setup manually or using the traditional schedule event. The prefix rule/ for the name is supported but optional for the plugin.

  2. To attach a rule defined by its full ARN, use the cloudWatchRuleArn property, such as in the counter-lambda example.

  3. The ANY keyword allow for any trigger under the current AWS account, so serverless does not need to run on every change to the project's infrastructure. In the example, a new timer can be added that triggers scalable-lambda with a different set of arguments, but developers do not need to run serverless deploy or use CLI to change the permissions on the function.