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 🙏

© 2024 – Pkg Stats / Ryan Hefner

accelerate-failover

v0.2.2

Published

[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)

Downloads

4

Readme

accelerate-failover

Conventional Commits pre-commit

accelerate-failover is a CLI tool to view the health and traffic status of AWS Elastic Beanstalks and shift traffic between regions in the event of a regional AWS outage. It finds all AWS Elastic Beanstalk applications that end in the stage name provided to the command i.e. dev2, dev, or qa. It then finds any AWS Route 53 weighted alias records for the Elastic Beanstalk environments that match our set identifiers, us-east-1 and us-west-2. If there are weighted records for an environment for both identifiers in the same hosted zone, then the application will toggle traffic to the primary or disaster recovery region.

Table of Contents

Requirements

Instructions

Installation

download binary

Download the accelerate-failover binary executable from the Releases page in this repository. Copy the binary to a file directory ~/bin/accelerate-failover and add ~/bin/ to your PATH if it is not on your path already.

build and package from source

To build and package the application to a binary source clone this repository and run:

yarn:

yarn
yarn build
yarn package:macos // alternately package:linux for a linux binary

npm:

npm i
npm run build
npm run package:macos // alternately package:linux for a linux binary

AWS Account Credentials

This tool will use the default AWS account profile on your machine. Use ALKS to set your default profile credentials for the account you want to run this script against.

accelerate-failover

Running the command without any options or with the -h or --help flags, will print the tool help menu.

$ accelerate-failover
accelerate-failover <command>

Commands:
  accelerate-failover failover <stage>      fail over traffic applications in
                                            the <stage> stage to the disaster
                                            recovery region
  accelerate-failover rollover <stage>      rollover traffic applications in the
                                            <stage> stage to the primary region
  accelerate-failover status <stage>        check the status of applications in
  <region>                                  the <region> region and <stage>
                                            stage

Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

accelerate-failover status <stage> <region>

$ accelerate-failover status -h
accelerate-failover status <stage> <region>

check the status of applications in the <region> region and <stage> stage

Positionals:
  region  the AWS Region [string] [required] [choices: "us-east-1", "us-west-2"]
  stage   the application stage
         [string] [required] [choices: "dev2", "dev", "qa", "uat", "production",
                                          "production-blue", "production-green"]

Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

$ accelerate-failover status dev2 us-east-1
checking status of Elastic Beanstalk Applications in ca-mmdnp us-east-1 dev2...
finding dev2 Elastic Beanstalk applications in account...
found dr-shopper-platform-dev2 Elastic Beanstalk environment...
found dr-dealstarter-dev2 Elastic Beanstalk environment...
finding weighted resource alias records in hosted zones in account...
found 12 weighted records in ca-mmdnp.makemydeal.com. hosted zone...
found resource record sets for dr-shopper-platform-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
found resource record sets for dr-dealstarter-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...

ca-mmdnp dev2 Elastic Beanstalk Environment Status us-east-1
┌───────────────────────────────┬───────────────┬───────────────────┬───────────────────┐
│ Elastic Beanstalk Environment │ Health Status │ us-east-1 Traffic │ us-west-2 Traffic │
├───────────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-shopper-platform-dev2      │ Ok            │ 100%              │ 0%                │
├───────────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-dealstarter-dev2           │ Ok            │ 100%              │ 0%                │
└───────────────────────────────┴───────────────┴───────────────────┴───────────────────┘

accelerate-failover failover <stage>

$ accelerate-failover failover -h
accelerate-failover failover <stage>

fail over traffic applications in the <stage> stage to the disaster recovery
region

Positionals:
  stage  [string] [required] [choices: "dev2", "dev", "qa", "uat", "production",
                                          "production-blue", "production-green"]

Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

$ accelerate-failover failover dev2
performing failover for dev2 shifting traffic to us-west-2...
finding dev2 Elastic Beanstalk applications in account...
found dr-shopper-platform-dev2
found dr-dealstarter-dev2
finding weighted resource records in hosted zones in account...
found 12 weighted records in ca-mmdnp.makemydeal.com. hosted zone...
found resource record sets for dr-shopper-platform-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
found resource record sets for dr-dealstarter-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
dr-shopper-platform-dev2 changing weight of us-east-1 record set to 0...
dr-shopper-platform-dev2 changing weight of us-west-2 record set to 100...
dr-dealstarter-dev2 changing weight of us-east-1 record set to 0...
dr-dealstarter-dev2 changing weight of us-west-2 record set to 100...
updating 2 records for dev2...
updating DNS record for shopper-platform-dev2-dr.ca-mmdnp.makemydeal.com.:us-east-1 weight: 0
updating DNS record for dealstarter-dev2-dr.ca-mmdnp.makemydeal.com.:us-east-1 weight: 0
adding shopper-platform-dev2-dr.ca-mmdnp.makemydeal.com.:us-west-2 weight: 100 to batch...
adding dealstarter-dev2-dr.ca-mmdnp.makemydeal.com.:us-west-2 weight: 100 to batch...
Applying batch update of 4 records for hosted zone /hostedzone/Z3BTVQ65IVZHGF...
hosted zone /hostedzone/Z3BTVQ65IVZHGF updates complete...
change set changes successfully updated to Route 53...

SUCCESSFULLY ROUTED dev2 TRAFFIC TO us-west-2

finding dev2 Elastic Beanstalk applications in account...
found dr-shopper-platform-dev2 Elastic Beanstalk environment...
found dr-dealstarter-dev2 Elastic Beanstalk environment...
finding weighted resource alias records in hosted zones in account...
found 12 weighted records in ca-mmdnp.makemydeal.com. hosted zone...
found resource record sets for dr-shopper-platform-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
found resource record sets for dr-dealstarter-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...

ca-mmdnp dev2 Elastic Beanstalk Status us-west-2:
┌──────────────────────────┬───────────────┬───────────────────┬───────────────────┐
│ Environment Name         │ Health Status │ us-east-1 Traffic │ us-west-2 Traffic │
├──────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-shopper-platform-dev2 │ Ok            │ 0%                │ 100%              │
├──────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-dealstarter-dev2      │ Ok            │ 0%                │ 100%              │
└──────────────────────────┴───────────────┴───────────────────┴───────────────────┘

accelerate-failover rollover <stage>

$ accelerate-failover rollover -h
accelerate-failover rollover <stage>

rollover traffic applications in the <stage> stage to the primary region

Positionals:
  stage  [string] [required] [choices: "dev2", "dev", "qa", "uat", "production",
                                          "production-blue", "production-green"]

Options:
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

$ accelerate-failover rollover dev2
performing rollover for dev2 shifting traffic to us-east-1...
finding dev2 Elastic Beanstalk applications in account...
found dr-shopper-platform-dev2
found dr-dealstarter-dev2
finding weighted resource records in hosted zones in account...
found 12 weighted records in ca-mmdnp.makemydeal.com. hosted zone...
found resource record sets for dr-shopper-platform-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
found resource record sets for dr-dealstarter-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
dr-shopper-platform-dev2 changing weight of us-east-1 record set to 100...
dr-shopper-platform-dev2 changing weight of us-west-2 record set to 0...
dr-dealstarter-dev2 changing weight of us-east-1 record set to 100...
dr-dealstarter-dev2 changing weight of us-west-2 record set to 0...
updating 2 records for dev2...
updating DNS record for shopper-platform-dev2-dr.ca-mmdnp.makemydeal.com.:us-east-1 weight: 100
updating DNS record for dealstarter-dev2-dr.ca-mmdnp.makemydeal.com.:us-east-1 weight: 100
adding shopper-platform-dev2-dr.ca-mmdnp.makemydeal.com.:us-west-2 weight: 0 to batch...
adding dealstarter-dev2-dr.ca-mmdnp.makemydeal.com.:us-west-2 weight: 0 to batch...
Applying batch update of 4 records for hosted zone /hostedzone/Z3BTVQ65IVZHGF...
hosted zone /hostedzone/Z3BTVQ65IVZHGF updates complete...
change set changes successfully updated to Route 53...

SUCCESSFULLY ROUTED dev2 TRAFFIC TO us-east-1!

finding dev2 Elastic Beanstalk applications in account...
found dr-shopper-platform-dev2 Elastic Beanstalk environment...
found dr-dealstarter-dev2 Elastic Beanstalk environment...
finding weighted resource alias records in hosted zones in account...
found 12 weighted records in ca-mmdnp.makemydeal.com. hosted zone...
found resource record sets for dr-shopper-platform-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...
found resource record sets for dr-dealstarter-dev2 in ca-mmdnp.makemydeal.com. /hostedzone/Z3BTVQ65IVZHGF...

ca-mmdnp dev2 Elastic Beanstalk Status us-east-1
┌──────────────────────────┬───────────────┬───────────────────┬───────────────────┐
│ Environment Name         │ Health Status │ us-east-1 Traffic │ us-west-2 Traffic │
├──────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-shopper-platform-dev2 │ Ok            │ 100%              │ 0%                │
├──────────────────────────┼───────────────┼───────────────────┼───────────────────┤
│ dr-dealstarter-dev2      │ Ok            │ 100%              │ 0%                │
└──────────────────────────┴───────────────┴───────────────────┴───────────────────┘

Settings

You can override settings in Settings.ts by setting the environment variable in the environment you are running this tool in.

export MAX_ATTEMPTS=10;  // this will set MAX_ATTEMPTS 10; overriding the default.
accelerate-faiover status dev2 us-east-1

Configurable values are:

export class Settings {
  // the resource record set identifier(recordId) of the disaster recovery DNS records
  public static DR_RECORD_SET_IDENTIFIER: string =
          process.env.DISASTER_RECOVERY_RECORD_SET_IDENTIFIER || 'us-west-2';
  /*
   * The AWS clients will retry 7 times by default with an exponential backoff at 100, 200, 400, 800, 1600, 3200, and
   * 6400 ms intervals, if the request fails after the summation of all of those attempts, roughly 13 seconds, the
   * script will throw an error.
   */
  public static MAX_ATTEMPTS: number = parseInt(
          process.env.MAX_ATTEMPTS || '7',
  );
  // the resource record set identifier(recordId) of the primary DNS records
  public static PRIMARY_RECORD_SET_IDENTIFIER: string =
          process.env.PRIMARY_RECORD_SET_IDENTIFIER || 'us-east-1';
  //...
  public static PRIMARY_REGION = process.env.PRIMARY_REGION || 'us-east-1';
  public static DR_REGION = process.env.DR_REGION || 'us-west-2';
  //...
}

CHANGELOG

see CHANGELOG.md.