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

aws-spot-price

v1.0.96

Published

CLI utility to list current global AWS EC2 Spot Instance prices.

Downloads

258

Readme

aws-spot-price

npm:latest

Build Status Quality Gate Status Coverage

Lists current global AWS EC2 Spot Instance prices.

Supports CLI and module usage.

CLI

Example

Example

Installation

npm

npm i aws-spot-price

yarn

yarn add aws-spot-price

run with npx

npx aws-spot-price

run with yarn dlx

yarn dlx aws-spot-price

Usage

aws-spot-run [options]

If no options are applied, it will fetch all recent pricing data from default regions and show top 30 cheapest instances.

Credentials

This CLI utility uses AWS-SDK and requires AWS Access & Secret keys. If environment variables pair AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY or ~/.aws/credentials is available it will use it. Otherwise, you will need to supply credentials through CLI options --accessKeyId and --secretAccessKey.

Permissions Required
  • ec2:DescribeSpotPriceHistory
  • ec2:DescribeInstanceTypes

Options

--ui

Start with UI mode.

--region | -r

AWS region to fetch data from. Accepts multiple string values. Defaults to all available AWS region which does not require opt-in.

example -r us-east-1 us-east-2
--family

EC2 instance families to filter. Will be translated to --familyType and --size values. Accepts multiple string values. Choose from: general, compute, memory, storage, acceleratedComputing

example -f general compute
--instanceType | -i

Type of EC2 instance to filter. Accepts multiple string values. Enter valid EC2 instance type name.

example -i t3.nano t3a.nano
--familyType | -f

EC2 Family type (c4, c5, etc..). Accepts multiple string values.

example -f c4 c5
--size | -s

EC2 size (large, xlarge, etc..). Accepts multiple string values.

example -s large xlarge
--minVCPU | --mc

Minimum vCPU count

Default: 1
--minMemoryGiB | --mm

Minimum memory size in GiB

Default: 0.5
--priceLimit | --pl

Maximum price limit.

Default: 100
--platforms | -p

Instance platforms types to filter. Accepts multiple string values. You can use linux or windows (all in lowercase) as wildcard.

Default: "Linux/UNIX" "Linux/UNIX (Amazon VPC)"
example -p windows "Red Hat Enterprise Linux"
--limit | -l

Limits list of price information items to be returned.

Default: 30
--reduceAZ | --raz

Reduce results with cheapest Availability Zone within Region

Default: true
--wide | -w

Output results with detail (vCPU, memory, etc)

Default: false
--json | -j

Outputs in JSON format. This option will silence any progress output.

--accessKeyId

Specific AWS Access Key ID. Requires --secretAccessKey option to be used together.

--secretAccessKey

Specific AWS Secret Access Key. Requires --accessKeyId option to be used together.

Module

Installation

npm

npm i aws-spot-price

yarn

yarn add aws-spot-price

Example

Code

import { getGlobalSpotPrices } from 'aws-spot-price';

(async () => {
  const results = await getGlobalSpotPrices({
    regions: ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2'],
    familyTypes: ['c5', 'c5a', 'c5ad', 'c5d', 'c5n', 'c6g', 'c6gd'],
    minMemoryGiB: 4,
    minVCPU: 2,
    limit: 5,
    reduceAZ: true,
  });
  console.log(JSON.stringify(results, null, 2));
})();

Results

  {
    "availabilityZone": "us-east-2c",
    "instanceType": "c5.large",
    "platform": "Linux/UNIX",
    "spotPrice": 0.019,
    "timestamp": "2020-11-19T15:18:07.000Z",
    "vCpu": 2,
    "memoryGiB": 4
  },
  {
    "availabilityZone": "us-east-2c",
    "instanceType": "c5a.large",
    "platform": "Linux/UNIX",
    "spotPrice": 0.019,
    "timestamp": "2020-11-19T22:04:26.000Z",
    "vCpu": 2,
    "memoryGiB": 4
  },
  {
    "availabilityZone": "us-east-2a",
    "instanceType": "c5d.large",
    "platform": "Linux/UNIX",
    "spotPrice": 0.019,
    "timestamp": "2020-11-19T05:58:45.000Z",
    "vCpu": 2,
    "memoryGiB": 4
  },
  {
    "availabilityZone": "us-east-2a",
    "instanceType": "c5n.large",
    "platform": "Linux/UNIX",
    "spotPrice": 0.019,
    "timestamp": "2020-11-20T02:27:24.000Z",
    "vCpu": 2,
    "memoryGiB": 5.25
  },
  {
    "availabilityZone": "us-east-2b",
    "instanceType": "c6g.large",
    "platform": "Linux/UNIX",
    "spotPrice": 0.02,
    "timestamp": "2020-11-19T13:41:03.000Z",
    "vCpu": 2,
    "memoryGiB": 4
  }
]