Skip to main content

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.

Metadata

Release files for aws-ec2-pricing 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-ec2-pricing 0.1.10
File Size Uploaded
aws-ec2-pricing-0.1.10.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-ec2-pricing 0.1.10
File Interpreter ABI Platform
aws_ec2_pricing-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / aws-ec2-pricing-0.1.10.tar.gz

Download URL aws-ec2-pricing-0.1.10.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f46a24476813f3c3052d323de3de630b2af9c5b1d4325a461bb2d5b6d4fecc2b
BLAKE2b-256 checksum
How to use checksums
af972eeaabd06e7bafc42ac0c1ca0c0bb2a7fd041d112366baa9595396d2e319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0

Release files / aws_ec2_pricing-0.1.10-py3-none-any.whl

Download URL aws_ec2_pricing-0.1.10-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
250e22f7068d18b8a025b4088ab5deb217febd21bb317032d392a6e1e173fe8f
BLAKE2b-256 checksum
How to use checksums
018a7026a459c42518c3ef6b43695f19a5d0494fd5ce5db0f4a24a53c1e256a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page