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 🙏

© 2026 – Pkg Stats / Ryan Hefner

aws-ec2-instance-running-scheduler

v3.0.4

Published

AWS CDK construct to run EC2 instances on a schedule (start/stop within working hours) using EventBridge Scheduler and a Durable Lambda.

Readme

AWS EC2 Instance Running Scheduler

GitHub npm (scoped) GitHub Workflow Status (branch) GitHub release (latest SemVer)

View on Construct Hub

AWS CDK construct to run EC2 instances on a schedule (start/stop within working hours) using EventBridge Scheduler and a Durable Lambda.

Features

  • Tag-based targeting – Select EC2 instances by tag key and values (e.g. Schedule / YES).
  • EventBridge Scheduler – Cron-based start and stop schedules with timezone support.
  • Durable Lambda – Single Lambda with AWS Lambda Durable Execution for reliable, long-running start/stop and polling (no Step Functions).
  • Slack notifications – Optional Slack messages for run results via Secrets Manager.
  • Scheduling toggle – Enable or disable scheduling without removing the stack (enableScheduling).
  • Configurable schedules – Separate cron settings for start and stop (minute, hour, week day, timezone).

Installation

npm

npm install aws-ec2-instance-running-scheduler

yarn

yarn add aws-ec2-instance-running-scheduler

Usage

Use the Construct EC2InstanceRunningScheduler when adding the scheduler into an existing Stack or any CDK scope.

import * as cdk from 'aws-cdk-lib';
import { TimeZone } from 'aws-cdk-lib';
import { EC2InstanceRunningScheduler } from 'aws-ec2-instance-running-scheduler';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyStack');

new EC2InstanceRunningScheduler(stack, 'EC2InstanceRunningScheduler', {
  targetResource: {
    tagKey: 'Schedule',
    tagValues: ['YES'],
  },
  secrets: {
    slackSecretName: 'my-slack-secret',
  },
  startSchedule: {
    timezone: TimeZone.ASIA_TOKYO,
    minute: '55',
    hour: '8',
    week: 'MON-FRI',
  },
  stopSchedule: {
    timezone: TimeZone.ASIA_TOKYO,
    minute: '5',
    hour: '19',
    week: 'MON-FRI',
  },
  enableScheduling: true,
});

Use the Stack EC2InstanceRunningScheduleStack when deploying the scheduler as a standalone stack.

import * as cdk from 'aws-cdk-lib';
import { TimeZone } from 'aws-cdk-lib';
import { EC2InstanceRunningScheduleStack } from 'aws-ec2-instance-running-scheduler';

const app = new cdk.App();

new EC2InstanceRunningScheduleStack(app, 'EC2InstanceRunningScheduleStack', {
  targetResource: {
    tagKey: 'Schedule',
    tagValues: ['YES'],
  },
  secrets: {
    slackSecretName: 'my-slack-secret',
  },
  startSchedule: {
    timezone: TimeZone.ASIA_TOKYO,
    minute: '55',
    hour: '8',
    week: 'MON-FRI',
  },
  stopSchedule: {
    timezone: TimeZone.ASIA_TOKYO,
    minute: '5',
    hour: '19',
    week: 'MON-FRI',
  },
  enableScheduling: true,
});

Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | targetResource | TargetResource | Yes | Tag key and values to select EC2 instances. | | secrets | Secrets | Yes | Slack secret name in AWS Secrets Manager. | | startSchedule | Schedule | No | Cron for starting instances (default: 07:50 MON–FRI UTC). | | stopSchedule | Schedule | No | Cron for stopping instances (default: 19:05 MON–FRI UTC). | | enableScheduling | boolean | No | Whether schedules are enabled (default: true). |

TargetResource

  • tagKey – Tag key used to select instances (e.g. Schedule).
  • tagValues – Tag values that match instances to include (e.g. ['YES']).

Schedule

  • timezoneTimeZone from aws-cdk-lib (e.g. TimeZone.ASIA_TOKYO, TimeZone.ETC_UTC).
  • minute – Cron minute (0–59).
  • hour – Cron hour (0–23).
  • week – Cron day of week (e.g. MON-FRI).

Secrets

  • slackSecretName – Name of the Secrets Manager secret containing Slack token and channel (JSON).

Requirements

  • Node.js ≥ 20.0.0
  • AWS CDK ^2.232.0
  • constructs ^10.5.1
  • AWS – EventBridge Scheduler, Lambda (Durable Execution), EC2, Resource Groups Tagging API, Secrets Manager

License

This project is licensed under the Apache-2.0 License.