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

ecs-statefulset

v0.1.0

Published

A reusable AWS CDK construct for deploying **stateful services** (like Zookeeper, Apache Pinot, etc.) on **ECS Fargate** with persistent storage using EBS Volumes and Snapshots with internal service discovery.

Downloads

1

Readme

StatefulSet CDK Construct

A reusable AWS CDK construct for deploying stateful services (like Zookeeper, Apache Pinot, etc.) on ECS Fargate with persistent storage using EBS Volumes and Snapshots with internal service discovery.

Key Features:

  • Stable DNS names for replicas
  • Ordered deployments and scale down
  • One EBS volume per replica that is snapshoted and recreated on scale down or task failure
  • Optional environment variable injection per task (e.g. index-based)
  • An managed Target Group accessible via the targetGroup property
  • Works by a simple Lambda control loop being executed by an Event Bridge Rule

Installation

Add this construct to your CDK project:

import { StatefulSet } from './stateful-set';

Usage Example: Zookeeper Cluster

new StatefulSet(this, 'ZookeeperStatefulSet', {
  vpc: vpc,
  name: 'zk',
  cluster: zookeeperCluster,
  taskDefinition: zookeeperTaskDefinition,
  hostedZone: hostedZone,
  securityGroup: zookeeperSecurityGroup,
  enableExecuteCommand: true,
  replicas: 3,
  environment: {
    ZOO_SERVERS: "server.0=zk-0.svc.internal:2888:3888;2181 server.1=zk-1.svc.internal:2888:3888;2181 server.2=zk-2.svc.internal:2888:3888;2181",
    ZOO_MY_ID: '$index'
  }
});
  • Each task will be reachable at zk-0.svc.internal, zk-1.svc.internal, etc.
  • The $index placeholder is automatically replaced with the task's index (0, 1, 2, ...)

Full Example with Apache Pinot

A full example demonstrating how to deploy a stateful Apache Pinot cluster using this construct is provided in:

src/demo/apachepinot.ts

To run the example:

npx tsc
cdk --app "npx ts-node src/demo/apachepinot.ts" deploy

This will compile the project and deploy the stack defined in apachepinot.ts using the AWS CDK.

Props

export interface StatefulSetProps {
  name: string; // Base name for the services and DNS records
  taskDefinition: ecs.FargateTaskDefinition;
  cluster: ecs.ICluster;
  hostedZone: route53.IHostedZone; // Used for DNS registration (e.g. zk-0.svc.internal)
  replicas: number; // Number of service instances to run
  subnets?: ec2.ISubnet[]; // Optional subnets to place the tasks in
  securityGroup: ec2.ISecurityGroup;
  environment?: Record<string, string>; // Optional environment variables
  vpc: ec2.IVpc;
  volumeSize?: number; // Optional volume size per task (in GiB)
  enableExecuteCommand?: boolean; // Enable ECS Exec for debugging
}

Service Discovery

The construct uses a Route 53 hosted zones to register each replica under a predictable DNS name:

<name>-<index>.<hostedZone>
e.g., zk-0.svc.internal

Target Group and Load Balancing

The construct exposes a targetGroup property which can be used to route traffic to all replicas.

Example:

loadBalancer.addListener('Listener', {
  port: 2181,
  defaultTargetGroups: [statefulSet.targetGroup],
});

Cleanup

All volumes and services are tagged with the name of the StatefulSet and can be managed via ess:<name>:managed tags for cleanup or lifecycle automation.