Skip to main content

CLI tool to build SQLite table from AWS EC2 prices.

Project description

aws-ec2-pricing

Table of AWS EC2 prices in SQL

Collect AWS EC2 prices from AWS API to SQL table to analyze them.

PyPI

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:

NameDescriptionExamples
familyInstace familyGeneral purpose, Compute optimized
typeInstace type groupa1, t3a, c5
sizeInstace sizenano, micro, xlarge, 32xlarge
burstIs instance burstable?Yes, No
baseBaseline performance of CPU (%)5, 10, 100
processorName of the physical CPUAWS Graviton, AMD EPYC
bitCPU bitness32-bit, 64-bit
archCPU architecturearm, x86
tenancyInstance tenancyShared, Dedicated, Host
regionAWS RegionUS East (Ohio), EU (Ireland)
vcpuNumber of virtual cores1, 2, 32
memoryAmount of RAM0.5 GiB, 128 GiB
storageStorage typeEBS only, 1x60GB NVM
osOperating SystemLinux
normNormalization scale factor (used by AWS to compare instances)0.5, 1.0, 8.0
speedDeclared CPU clock speed2.5 GHz, Up to 3.2 Ghz. 0 GHz
actualActual CPU clock speed multiplied by baseline0.125 GHz, 2.5 Ghz
networkNetwork performanceUp to 3500 MiB
genIs it current generation of instances?Yes, No
curPrice currencyUSD, CNY
hourlyHourly price0.0255
montlyMonthly price (hourly * 24 * 30)3.844
startingDate from which Amazon offers this price2021-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-ec2-pricing-0.1.10.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

aws_ec2_pricing-0.1.10-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

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

Hashes for aws-ec2-pricing-0.1.10.tar.gz
Algorithm Hash digest
SHA256 f46a24476813f3c3052d323de3de630b2af9c5b1d4325a461bb2d5b6d4fecc2b
MD5 27b0e7fe38fa2c2d06ff9243fc7cbd0f
BLAKE2b-256 af972eeaabd06e7bafc42ac0c1ca0c0bb2a7fd041d112366baa9595396d2e319

See more details on using hashes here.

File details

Details for the file aws_ec2_pricing-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_ec2_pricing-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 250e22f7068d18b8a025b4088ab5deb217febd21bb317032d392a6e1e173fe8f
MD5 f3914670ef027bf556ab9954aad63312
BLAKE2b-256 018a7026a459c42518c3ef6b43695f19a5d0494fd5ce5db0f4a24a53c1e256a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page