CLI tool to build SQLite table from AWS EC2 prices.
Project description
aws-ec2-pricing
Collect AWS EC2 prices from AWS API to SQL table to analyze them.
Table of contents:
Usage
Make sure AWS credentials are set as environment variables or are available otherwise to boto3
library
which this program uses to connect to AWS API.
Usage: ec2pricing [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
build Build SQLite database with prices from given JSON
download Download EC2 prices to JSON file
Download all "On Demand" prices for all regions for "Shared" instances into a JSON file.
ec2pricing download
Build a SQLite database from that JSON file.
You can see an example of built database in examples/prices.db
file in this repo.
ec2pricing build
The resulting file is a SQLite database with a single prices
table in it.
Resulting table prices
in the prices.db
file has following columns:
Name | Description | Examples |
---|---|---|
family | Instace family | General purpose, Compute optimized |
type | Instace type group | a1, t3a, c5 |
size | Instace size | nano, micro, xlarge, 32xlarge |
burst | Is instance burstable? | Yes, No |
base | Baseline performance of CPU (%) | 5, 10, 100 |
processor | Name of the physical CPU | AWS Graviton, AMD EPYC |
bit | CPU bitness | 32-bit, 64-bit |
arch | CPU architecture | arm, x86 |
tenancy | Instance tenancy | Shared, Dedicated, Host |
region | AWS Region | US East (Ohio), EU (Ireland) |
vcpu | Number of virtual cores | 1, 2, 32 |
memory | Amount of RAM | 0.5 GiB, 128 GiB |
storage | Storage type | EBS only, 1x60GB NVM |
os | Operating System | Linux |
norm | Normalization scale factor (used by AWS to compare instances) | 0.5, 1.0, 8.0 |
speed | Declared CPU clock speed | 2.5 GHz, Up to 3.2 Ghz. 0 GHz |
actual | Actual CPU clock speed multiplied by baseline | 0.125 GHz, 2.5 Ghz |
network | Network performance | Up to 3500 MiB |
gen | Is it current generation of instances? | Yes, No |
cur | Price currency | USD, CNY |
hourly | Hourly price | 0.0255 |
montly | Monthly price (hourly * 24 * 30) | 3.844 |
starting | Date from which Amazon offers this price | 2021-09-01T00:00:00Z |
The built database can be opened in any SQL IDE, for example, DBeaver (open source SQL editor) or in any other way. You can then run queries in it.
Show cheapest x86-64 virtual machines:
SELECT * FROM prices WHERE arch = 'x86'
ORDER BY monthly;
Show cheapest ARM machines in Ireland:
SELECT * FROM prices
WHERE arch = 'arm' AND region = "EU (Ireland)"
ORDER BY monthly;
Sort all machines alpabetically by their family, type and power:
SELECT * FROM prices
ORDER BY family, type, norm;
Limitations
Currently, downloaded prices are limited to instances with:
- "Shared" tenancy
- "Linux" operating system
- Support for VPC networking
- Only "On Demand" pricing, no reserved instances or saving plans
- "Used" capacity reservation
All these are default settings for EC2 instances when you check prices for them on AWS pricng website.
Installation
This program is written in Python and can be installed via pip
.
pip install aws-ec2-pricing
Build it and run it yourself
Set up via pip and virtual environemnt
-
Create a virtual environment
python3 -m venv .venv source ./.venv/bin/activate
-
Install requirements into it
pip install -r requirements.txt
-
Run the program
python3 ec2pricing/__init__.py download
Set up via poetry
-
Tell poetry which version of python available in your system to use
poetry env use 3.9.7
-
Install dependencies and create virtual environment
poetry install
-
Run program
poetry run ec2pricing download
Feature plans
- Static website that displays the table along with the filters
- Add search filters as key-value pairs for initial price download
- Search for instances other than shared or Linux based
- Support saving plans, reserved instances, free tier
Copyright & License
- This program is distributed under Apache 2 License.
- All AWS and Amazon related trademarks or symbols are not mine.
- Prices obtained through this program are not an offer and should not be treated as official.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aws-ec2-pricing-0.1.10.tar.gz
.
File metadata
- Download URL: aws-ec2-pricing-0.1.10.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f46a24476813f3c3052d323de3de630b2af9c5b1d4325a461bb2d5b6d4fecc2b |
|
MD5 | 27b0e7fe38fa2c2d06ff9243fc7cbd0f |
|
BLAKE2b-256 | af972eeaabd06e7bafc42ac0c1ca0c0bb2a7fd041d112366baa9595396d2e319 |
File details
Details for the file aws_ec2_pricing-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: aws_ec2_pricing-0.1.10-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 250e22f7068d18b8a025b4088ab5deb217febd21bb317032d392a6e1e173fe8f |
|
MD5 | f3914670ef027bf556ab9954aad63312 |
|
BLAKE2b-256 | 018a7026a459c42518c3ef6b43695f19a5d0494fd5ce5db0f4a24a53c1e256a8 |