AWS offers a Bulk API, which returns large JSON files containing all price points for each service or a Query API, which requires AWS credentials and an IAM user.
This project creates a GraphQL API using the data from the AWS Price List Bulk API.
This project currently uses a generic GraphQL schema to represent all AWS products. Future work might move to using schemas for each distinct AWS product.
Get all t3.micro prices in US East, this returns 30+ results. Try it yourself by pasting the query into https://aws-prices-graphql.alistair.scot/graphql. This is running on minimal infrastructure so is not guaranteed to always be available.
query {
products(
filter: {
attributes: [
{ key: "servicecode", value: "AmazonEC2" },
{ key: "instanceType", value: "t3.micro" },
{ key: "location", value: "US East (N. Virginia)" }
]
},
) {
attributes { key, value }
onDemandPricing {
priceDimensions {
pricePerUnit {
USD
}
}
}
}
}
Get the hourly on-demand price of a Linux EC2 t3.micro instance in US East:
Request:
query {
products(
filter: {
attributes: [
{ key: "servicecode", value: "AmazonEC2" },
{ key: "instanceType", value: "t3.micro" },
{ key: "location", value: "US East (N. Virginia)" }
{ key: "tenancy", value: "Shared" }
{ key: "operatingSystem", value: "Linux"}
{ key: "capacitystatus", value: "Used" }
{ key: "preInstalledSw", value: "NA"}
]
},
) {
onDemandPricing {
priceDimensions {
pricePerUnit {
USD
}
}
}
}
}
Response:
{
"data": {
"products": [
{
"onDemandPricing": [
{
"priceDimensions": [
{
"pricePerUnit": {
"USD": "0.0104000000"
}
}
]
}
]
}
]
}
}
- Node.js >= 12.18.0
- MongoDB >= 3.6
- Clone the repo
git clone https://github.com/aliscott/aws-prices-graphql.git
cd aws-prices-graphql
- Add a
.env
file to point to your MongoDB server, e.g.
MONGODB_URI=mongodb://localhost:27017/awsPricing
- Install the npm packages
npm install
- Download the AWS pricing files into the
data
directory. Note: this downloads about 1.8 GB of data
npm run downloadPrices
- Load the prices into MongoDB
npm run loadPrices
npm start
You can now access the GraphQL Playground at http://localhost:4000/graphql.
- Product-specific schemas - can we auto-generate these?
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.