Skip to content

Instantly share code, notes, and snippets.

@cjwfuller
Created March 24, 2016 00:36
Show Gist options
  • Save cjwfuller/3787d8387b9e8e588514 to your computer and use it in GitHub Desktop.
Save cjwfuller/3787d8387b9e8e588514 to your computer and use it in GitHub Desktop.
Script to get AWS EC2 spot instance pricing
'use strict';
let AWS = require('aws-sdk');
let ec2 = new AWS.EC2({
region: 'ap-southeast-2',
});
let params = {
DryRun: false,
InstanceTypes: [
'm3.medium',
],
ProductDescriptions: [
'Linux/UNIX',
],
};
ec2.describeSpotPriceHistory(params, function (err, data) {
if (err) {
console.log(err, err.stack);
} else {
console.log(data);
}
});
{ SpotPriceHistory:
[ { InstanceType: 'm3.medium',
ProductDescription: 'Linux/UNIX',
SpotPrice: '0.014700',
Timestamp: Thu Mar 24 2016 11:17:42 GMT+1100 (AEDT),
AvailabilityZone: 'ap-southeast-2c' },
{ InstanceType: 'm3.medium',
ProductDescription: 'Linux/UNIX',
SpotPrice: '0.014500',
Timestamp: Thu Mar 24 2016 11:16:36 GMT+1100 (AEDT),
AvailabilityZone: 'ap-southeast-2c' },
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment