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 🙏

© 2025 – Pkg Stats / Ryan Hefner

local-aws-secrets-manager

v0.0.2

Published

> Run AWS Secrets Manager locally without external dependencies.

Readme

Local AWS Secrets Manager

Run AWS Secrets Manager locally without external dependencies.

Install

npm i local-aws-secrets-manager --save-dev
# yarn add -D local-aws-secrets-manager

Usage

import { createSecretsManagerServer } from "local-aws-secrets-manager";
// const { createSecretsManagerServer } = require("local-aws-secrets-manager");

const { server, port } = await createSecretsManagerServer();

Options

| name | default | description | | ------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | port | 0 (random) | The port used by Node.js http createServer | | hostname | localhost | The hostname used by Node.js http createServer | | region | us-east-1 | (Cosmetic) AWS Region used in the Secret ARN. | | accountId | 123456789012 | (Cosmetic) AWS Account ID used in Secret ARNs. | | invokeLambdaForRotation | | A function with the signature (RotationLambdaARN: string, event: RotationEvent) => Promise<any>. You are responsible for invoking the Lambda function using your preferred method. | | rotationIntervalInSeconds | 10 | See #Notes | | maxRotationCount | 2 | See #Notes | | secrets | {} | A record of secrets to create when the server starts. Keys can be Secret Names or valid Secret ARNs. Each config object can include: ClientRequestToken, SecretString, SecretBinary, Description, Tags, OwningService, KmsKeyId, |

Integration

AWS provides a feature called Service-specific endpoints, which allows you to redirect all AWS Secrets Manager API requests to a specific endpoint. If your app already uses AWS credentials and region settings, you can simply set the AWS_ENDPOINT_URL_SECRETS_MANAGER environment variable to redirect all Secrets Manager requests to your local instance:

AWS_ENDPOINT_URL_SECRETS_MANAGER=http://localhost:5432 node ./myApp.js

Setup based on AWS Profile: inside ~/.aws/config file

[profile local]
aws_access_key_id=fake
aws_secret_access_key=fake
region=us-east-1
services = local-services

[services local-services]
secrets_manager =
  endpoint_url = http://localhost:5432

Using with AWS SDK

with AWS_PROFILE=local (or AWS_ENDPOINT_URL_SECRETS_MANAGER) env variable

import { SecretsManagerClient, CreateSecretCommand } from "@aws-sdk/client-secrets-manager";

const client = new SecretsManagerClient({});

const cmd = new CreateSecretCommand({ Name: "db-password", SecretString: "supersecret" });

const res = await client.send(cmd);

console.log(res.VersionId);
// 1258b779-94f9-47ba-a162-f946d06dd9c2

without AWS_PROFILE=local

import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";

const client = new SecretsManagerClient({
  region: "us-east-1",
  endpoint: `http://localhost:5432`,
  credentials: {
    accessKeyId: "fake",
    secretAccessKey: "fake",
  },
});

Using with AWS CLI

with AWS_PROFILE=local or aws --profile local

aws --profile local secretsmanager create-secret --name MyFirstLocalSecret

# output
{
    "ARN": "arn:aws:secretsmanager:us-east-1:123456789012:secret:MyFirstLocalSecret-Hi17HX",
    "Name": "MyFirstLocalSecret"
}

without AWS_PROFILE

AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test aws --region us-east-1 --endpoint-url http://localhost:5432 secretsmanager create-secret --name MyFirstLocalSecret

# output
{
    "ARN": "arn:aws:secretsmanager:us-east-1:123456789012:secret:MyFirstLocalSecret-Hi17HX",
    "Name": "MyFirstLocalSecret"
}

Using with Terraform

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.46.0"
    }

  }
}

# Without AWS_PROFILE

# provider "aws" {
#   region                      = "us-east-1"
#   access_key                  = "fake"
#   secret_key                  = "fake"
#   skip_credentials_validation = true
#   skip_requesting_account_id  = true
#   endpoints {
#     secrets_manager = "http://localhost:5432"
#   }
# }


# With AWS Profile

provider "aws" {
  profile = "local"
  skip_credentials_validation = true
  skip_requesting_account_id  = true
}


resource "aws_secretsmanager_secret" "my_secret" {
  name = "MyFirstLocalSecret"
}

Using with Jest

jest.config.js

/** @type {import('jest').Config} */
const config = {
  globalSetup: "./setup-secretsmanager.js",
  globalTeardown: "./teardown-secretsmanager.js",
};

module.exports = config;

setup-secretsmanager.js

// @ts-check
const { createSecretsManagerServer } = require("local-aws-secrets-manager");

module.exports = async () => {
  const { server } = await createSecretsManagerServer({ port: 5432, secrets: { MyFirstLocalSecret: { StringValue: "supersecret" } } });
  global.__SECRETS_MANAGER_SERVER__ = server;
};

teardown-secretsmanager.js

module.exports = async () => {
  global.__SECRETS_MANAGER_SERVER__.close();
};

Using with Vitest

vitest.config.ts

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    globalSetup: ["secretsmanager.config.ts"],
  },
});

secretsmanager.config.ts

import { createSecretsManagerServer } from "local-aws-secrets-manager";
import type { Server } from "http";

let server: Server;

export const setup = async () => {
  server = (await createSecretsManagerServer({ port: 5432, secrets: { MyFirstLocalSecret: { StringValue: "supersecret" } } })).server;
};

export const teardown = () => {
  server.close();
};

Supported Commands

| Command Name | Supported | | ---------------------------- | --------- | | BatchGetSecretValue | ✅ | | CancelRotateSecret | ✅ | | CreateSecret | ✅ | | DeleteResourcePolicy | ✅ | | DeleteSecret | ✅ | | DescribeSecret | ✅ | | GetRandomPassword | ✅ | | GetResourcePolicy | ✅ | | GetSecretValue | ✅ | | ListSecrets | ✅ | | ListSecretVersionIds | ✅ | | PutResourcePolicy | ✅ | | PutSecretValue | ✅ | | RemoveRegionsFromReplication | ✅ | | ReplicateSecretToRegions | ✅ | | RestoreSecret | ✅ | | RotateSecret | ✅ | | StopReplicationToReplica | ✅ | | TagResource | ✅ | | UntagResource | ✅ | | UpdateSecret | ✅ | | UpdateSecretVersionStage | ✅ | | ValidateResourcePolicy | ✅ |

Creating Secrets from a File

local-aws-secrets-manager also exports getSecretsFromFile which allows you to load secrets from an existing .env or .json file.

Example:

import { createSecretsManagerServer, getSecretsFromFile } from "local-aws-secrets-manager";

const { server, port } = await createSecretsManagerServer({ secrets: getSecretsFromFile("path/to/.env") });

Notes

Since this tool is designed for local development, certain behaviors are intentionally simplified or ignored:

  • RotationRules's parameters such as AutomaticallyAfterDays, Duration, and ScheduleExpression are not used duration rotation.
    Use rotationIntervalInSeconds and maxRotationCount to control rotation timing.
  • No permission checks are performed (Access Keys, Policies, KMS, etc.).
  • Invalid regions do not throw errors.