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-step-cloner

v1.0.3

Published

A CLI and utility tool to clone AWS Step Functions with all associated states, parameters, and configurations.

Downloads

12

Readme

AWS Step Cloner

Apache License

MIT License

aws-step-cloner is a Node.js utility that lets you download, clone, and re-upload AWS Step Functions along with all their corresponding AWS Lambda functions — in just a few lines of code.

It’s designed to make migrating, replicating, or backing up AWS workflows fast and seamless.


📦 Installation

Install via npm:

npm install aws-step-cloner

or via yarn:

yarn add aws-step-cloner

⚙️ Features

  • Download Step Functions along with all referenced Lambda functions
  • Upload cloned Step Functions with new Lambda ARNs
  • One-click workflow duplication across AWS regions or accounts
  • Automatic ARN mapping — no manual edits required
  • Lightweight, dependency-efficient, and easy to integrate

🔑 Prerequisites

Before using the library, ensure you have:

An AWS IAM User or Role with the following permissions: 1. states 2. lambda: 3. iam:PassRole A valid StepFunctionRole and LambdaExecutionRole AWS credentials (Access Key & Secret Key)


1. Using the Downloader Class

The Downloader class helps you download an existing AWS Step Function along with all its Lambda functions to a local directory.

Example:

import { Downloader } from "aws-step-cloner";

const downloader = new Downloader();

const response = await downloader.download({
  accessKeyId: "<YOUR_AWS_ACCESS_KEY_ID>",
  secretAccessKey: "<YOUR_AWS_SECRET_ACCESS_KEY>",
  region: "ap-south-1",
  stateMachineArn: "arn:aws:states:ap-south-1:<YOUR_ACCOUNT_ID>:stateMachine:MySampleMachine",
  outputDir: "./south-downloaded",
});

Output: A new folder south-downloaded will be created containing:

  • definition.json → the Step Function definition schema
  • .zip files → code for all Lambda functions used in the workflow

2. Using the Uploader Class

The Uploader class allows you to recreate Step Functions and Lambda functions from a previously downloaded schema.

It automatically updates Lambda ARNs in the Step Function definition and creates a new Step Function.

Example:

import { Uploader } from "aws-step-cloner";

const uploader = new Uploader();

const uploadResponse = await uploader.upload({
  accessKeyId: "<YOUR_AWS_ACCESS_KEY_ID>",
  secretAccessKey: "<YOUR_AWS_SECRET_ACCESS_KEY>",
  region: "ap-south-1",
  stateMachineName: "MySampleMachine",
  definition: response.definition,
  roleArn: "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/StepFunctionRole",
  lambdaDir: "./south-downloaded",
  lambdaExecutionRoleArn: "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/LambdaExecutionRole",
  prefix: "clone-",
  stepFunctionDefinitionPath: response.definition,
  stepFunctionName: "MyStepFunctionClone",
});

Notes:

  • The prefix is added to cloned resource names to avoid conflicts.
  • Make sure your roles (StepFunctionRole, LambdaExecutionRole) have the correct permissions.
  • You can reuse the folder generated by the Downloader.

3. Environment Variables Handling

AWS Step Cloner supports two ways of managing Lambda environment variables:

a) Use existing environment variables (envIncluded)

  • If you want to reuse the environment variables fetched during download:
const uploadResponse = await uploader.upload({
  ...
  envIncluded: true, // Use previously downloaded env variables
});

b) Use a custom environment JSON file (envFilePath)

Provide a JSON file with environment variables for each Lambda:

{
  "Myfirst": {
    "DB_URI": "asdadsadasdadsda",
    "Key": "adsadasdadad",
    "Secret": "adsadasdadad",
    "db": "mydatabase",
    "port": 5432,
    "host": "localhost"

  },
  "MySecond": {
    "DB_URI": "sadsadasdasd",
    "key": "adsadadasds",
    "Secret": "adsadasdadad",
    "db": "mydatabase",
    "port": 5432,
    "host": "localhost"
  }
}

Noted: If you don't pass any option then the functions will create with no environment variables


Combined Usage (Recommended)

You can use both classes in a single script to download and re-upload a Step Function and its Lambdas in one go.

Example:

import { Downloader, Uploader } from "aws-step-cloner";

// Step 1: Download
const downloader = new Downloader();
const response = await downloader.download({
  accessKeyId: "<YOUR_AWS_ACCESS_KEY_ID>",
  secretAccessKey: "<YOUR_AWS_SECRET_ACCESS_KEY>",
  region: "ap-south-1",
  stateMachineArn: "arn:aws:states:ap-south-1:<YOUR_ACCOUNT_ID>:stateMachine:MySampleMachine",
  outputDir: "./south-downloaded",
});

// Step 2: Upload
const uploader = new Uploader();
const uploadResponse = await uploader.upload({
  accessKeyId: "<YOUR_AWS_ACCESS_KEY_ID>",
  secretAccessKey: "<YOUR_AWS_SECRET_ACCESS_KEY>",
  region: "ap-south-1",
  stateMachineName: "MySampleMachine",
  definition: response.definition,
  roleArn: "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/StepFunctionRole",
  lambdaDir: "./south-downloaded",
  lambdaExecutionRoleArn: "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/LambdaExecutionRole",
  prefix: "clone-",
  stepFunctionDefinitionPath: response.definition,
  stepFunctionName: "MyStepFunctionClone",
});

Example Output:

--- Downloaded Step Function definition
--- Downloaded Lambdas: [MyLambdaOne, MyLambdaTwo]
--- Created Lambdas: clone-MyLambdaOne, clone-MyLambdaTwo
--- Created Step Function: arn:aws:states:ap-south-1:123456789012:stateMachine:clone-MyStepFunctionClone
--- Clone completed successfully!

How It Works

Downloader

  • Calls AWS Step Functions API to fetch the state machine definition.
  • Scans the definition for Lambda ARNs.
  • Downloads each Lambda code as a .zip file.
  • Saves all files locally.

Uploader

  • Reads downloaded .zip Lambda files.
  • Creates new Lambda functions.
  • Updates the Step Function definition with the new ARNs.
  • Deploys a new Step Function.

Common Issues

| Problem | Cause | Solution | | -------------------------------------------- | --------------------------------------- | ------------------------------------------------ | | AccessDeniedException: iam:PassRole | IAM user lacks role-passing permission | Attach policy with "Action": "iam:PassRole" | | The "path" argument must be of type string | Passed an object instead of string path | Use actual JSON file path, not parsed object | | ResourceConflictException | Duplicate Step Function name | Use a unique prefix for cloning (e.g., clone-) |


License

This project is dual-licensed under either:

Author

Developed with ❤️ by Syed Bakhtawar Fahim

Software Engineer | Backend & Cloud

Support

If you found this package helpful:

  • Star ⭐ the repository
  • Contribute via pull requests
  • Share your feedback and feature ideas