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

clone-ami-to-region

v0.1.1

Published

Copy an AMI to another region, duplicating tags and launch permissions.

Downloads

1

Readme

Clone an AMI to Another Region

Amazon provides an API endpoint to copy an AMI from one region to another. Unfortunately it doesn't copy over launch permissions and tags. When building AMIs for a service that is distributed across multiple regions, this can be quite annoying, as one usually wants the same launch permissions, name, and other tags to be applied to the copied AMIs.

It doesn't sound onerous to copy the tags and permissions over, but in the context of a bash script or other devops code, it is actually a fair few commands, as well as needed error handling and retries. Abstracting that into a single package like this is helpful; it saves time when there are scores of different applications and devops setups that need the task performed.

The devops model that this package helps with is as follows: create a single AMI for a release in one environment and region, then clone it to all desired regions. Deploy new stacks based on that AMI and use an instance userdata script to apply the correct configuration for the run environment as the instance comes up.

Installation

npm install clone-ami-to-region

Scope of Cloning

This only copies over the following items to the new AMI in the new region:

  • Name.
  • Description.
  • Tags.
  • Launch permissions.

None of the other image attributes should be copied in such a scenario, as they are either involved in other processes where the cloning is done for you (such as product codes and the marketplace), or cannot be set via the EC2 API in any case.

Usage

var cloneAmiToRegion = require('clone-ami-to-region');

cloneAmiToRegion.cloneImage({

  // --------------------------------------------------------------
  // Required configuration.
  // --------------------------------------------------------------

  // Provide the source AMI ID.
  sourceImageId: 'ami-11223344',

  // The region that contains the source AMI.
  sourceRegion: 'us-east-1',

  // An array of regions to clone the AMI to.
  destinationRegions: [
    'eu-west-1',
    'eu-west-2'
  ],

  // --------------------------------------------------------------
  // Optional configuration.
  // --------------------------------------------------------------

  // AWS credentials will be taken from the environment if not provided, and
  // that is the preferred methodology. Credentials and other configuration can
  // be provided directly, however.
  // clientOptions: {
  //   accessKeyId: 'akid',
  //   secretAccessKey: 'secret'
  // }

  // It usually takes a few minutes for a copy to complete. This determines the
  // frequency with which completion is checked.
  progressCheckIntervalInSeconds: 30,

}, function (error, results) {
  if (error) {
    console.error(error);
  }

  // A results object is always returned, regardless of error status. It shows
  // the details of success or failure for each of the destinaton regions. It
  // has the form:
  //
  // {
  //   'eu-west-1': {
  //     imageId: 'ami-11223344',
  //     success: true
  //   },
  //   'us-west-2': {
  //     error: new Error(''),
  //     success: false
  //   },
  //   ...
  // }
  //
  console.info(JSON.stringify(results, null, '  '));
});