aws-spot-price
TypeScript icon, indicating that this package has built-in type declarations

1.0.96 • Public • Published

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
  }
]

Package Sidebar

Install

npm i aws-spot-price

Weekly Downloads

96

Version

1.0.96

License

MIT

Unpacked Size

1.04 MB

Total Files

9

Last publish

Collaborators

  • hoonoh