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

@matthewbonig/nightynight

v2.0.2

Published

A CDK construct that will automatically stop a running EC2 instance at a given time.

Downloads

31

Readme

NightyNight and WakeyWakey!

Do you have a EC2 instance or an RDS instance that you only need during certain hours of the day? Do you want to reduce it's cost? How about just stopping it every night?

That's the NightyNight construct. It's very simple. Give it an instanceId and it will create a Lambda and a CloudWatch Event Rule to fire the lambda at a specific time of day. If the instance is running, it's stopped.

There are currently two variations of the construct:

WakeyWakey

The WakeyWakey construct (from this repository) has been integrated into this library. You don't need to install a separate dependency anymore.

There isn't a specific construct for starting ASGs or ECS services, since you can just set the count to whatever you want.

This is a pre-release!

This is a quick first-draft. All the options that will likely need to be added to accommodate a large number of use-cases are still needed. If you'd like to make requests or help update this construct, please open an Issue or a PR.

There are multiple versions of this library published. You should be using the v0.X.X versions for now. There are versions published that match the CDK version they depend on, but don't use those.

What it creates

arch.png

  • A Rule that will, on a given schedule, fire a lambda.
  • A Lambda with permissions to describe ec2 instances. It will read the instance by the given instanceId and then stop the instance if it's in a running state.

Example:

import {NightyNightForEc2, WakeyWakeyForEc2} from "./ec2";

export class NightyNightStack extends Stack {

  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    // The code that defines your stack goes here
    new NightyNightForEc2(this, 'nighty-night', {instanceId: 'i-123123123123'});
    new WakeyWakeyForEc2(this, 'wakey-wakey', {instanceId: 'i-123123123123'})
  }
}

This will stop the instance with id i-123123123123 at (the default) 4am UTC. It will then start the instance at 12am UTC.

API Doc

See the API Docs for more info.

Contributing

Please open Pull Requests and Issues on the Github Repo.

License

MIT