Lists current global AWS EC2 Spot Instance prices.
Supports CLI and module usage.
npm i aws-spot-price
yarn add aws-spot-price
npx aws-spot-price
yarn dlx aws-spot-price
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.
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
.
- ec2:DescribeSpotPriceHistory
- ec2:DescribeInstanceTypes
Start with UI mode.
AWS region to fetch data from. Accepts multiple string values. Defaults to all available AWS region which does not require opt-in.
EC2 instance families to filter. Will be translated to --familyType
and --size
values.
Accepts multiple string values.
Choose from: general
, compute
, memory
, storage
, acceleratedComputing
Type of EC2 instance to filter. Accepts multiple string values. Enter valid EC2 instance type name.
EC2 Family type (c4
, c5
, etc..). Accepts multiple string values.
EC2 size (large
, xlarge
, etc..). Accepts multiple string values.
Minimum vCPU count
Minimum memory size in GiB
Maximum price limit.
Instance platforms types to filter. Accepts multiple string values.
You can use linux
or windows
(all in lowercase) as wildcard.
Instance architecture types to filter. Accepts multiple string values.
Limits list of price information items to be returned.
Reduce results with cheapest Availability Zone within Region
Output results with detail (vCPU, memory, etc)
Outputs in JSON format. This option will silence any progress output.
Specific AWS Access Key ID. Requires --secretAccessKey
option to be used together.
Specific AWS Secret Access Key. Requires --accessKeyId
option to be used together.
npm i aws-spot-price
yarn add aws-spot-price
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,
architectures: ['arm64', 'x86_64']
});
console.log(JSON.stringify(results, null, 2));
})();
[
{
"availabilityZone": "us-east-2c",
"instanceType": "t4g.medium",
"platform": "Linux/UNIX",
"architectures": [
"arm64"
],
"spotPrice": 0.0083,
"timestamp": "2024-05-16T10:31:10.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"availabilityZone": "us-west-2a",
"instanceType": "c7a.large",
"platform": "Linux/UNIX",
"architectures": [
"x86_64"
],
"spotPrice": 0.0103,
"timestamp": "2024-05-15T16:09:23.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"availabilityZone": "us-west-1b",
"instanceType": "c7i-flex.large",
"platform": "Linux/UNIX",
"architectures": [
"x86_64"
],
"spotPrice": 0.0108,
"timestamp": "2024-05-16T04:16:55.000Z",
"vCpu": 2,
"memoryGiB": 4
},
{
"availabilityZone": "us-west-2d",
"instanceType": "m7a.large",
"platform": "Linux/UNIX",
"architectures": [
"x86_64"
],
"spotPrice": 0.0117,
"timestamp": "2024-05-16T00:47:33.000Z",
"vCpu": 2,
"memoryGiB": 8
},
{
"availabilityZone": "us-west-2b",
"instanceType": "t3a.medium",
"platform": "Linux/UNIX",
"architectures": [
"x86_64"
],
"spotPrice": 0.0129,
"timestamp": "2024-05-16T09:02:05.000Z",
"vCpu": 2,
"memoryGiB": 4
}
]