spotinfo
The spotinfo
is a command-line tool that helps you determine AWS Spot instance types with the least chance of interruption and provides the savings you get over on-demand rates.
You should weigh your application’s tolerance for interruption and your cost saving goals when selecting a Spot instance. The lower your interruption rate, the longer your Spot instances are likely to run.
Usage
With spotinfo
command you can get a filtered and sorted list of Spot instance types as a plain text, json, pretty table or CSV format.
spotinfo --help
NAME:
spotinfo - spotinfo CLI
USAGE:
spotinfo [global options] command [command options] [arguments...]
VERSION:
1.0.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--type value EC2 instance type (can be RE2 regexp patten)
--os value instance operating system (windows/linux) (default: "linux")
--region value AWS region (default: "us-east-1")
--output value format output: number|text|json|table|csv (default: "table")
--cpu value filter: minimal vCPU cores (default: 0)
--memory value filter: minimal memory GiB (default: 0)
--price value filter: maximum price per hour (default: 0)
--sort value sort results by interruption|type|savings|price (default: "interruption")
--help, -h show help (default: false)
--version, -v print the version (default: false)
Data Sources
The spotinfo
uses the following data sources to get updated information about AWS EC2 Spot instances:
- AWS Spot Advisor JSON file, maintained/updated by AWS team
- AWS Spot Pricing
callback
JS file, maintained/updated by AWS team
The spotinfo
also includes embedded (during the build) copies of the above files, and thus can continue to work, even if there is no network connectivity, or these files are not available, for any reason.
Example
Get all Graviton2 Linux Spot instances in the AWS Oregon (us-west-2
) region, with CPU cores > 8 and memory > 64gb, sorted by type, and output the result in a table format.
Run spotinfo CLI
# run binary
spotinfo --type="^.(6g)(\S)*" --cpu=8 --memory=64 --region=us-west-2 --os=linux --output=table --sort=type
# OR run Docker image
docker run -it --rm ghcr.io/alexei-led/spotinfo --type="^.(6g)(\S)*" --cpu=8 --memory=64 --region=us-west-2 --os=linux --output=table --sort=type
Output:
┌───────────────┬──────┬────────────┬────────────────────────┬───────────────────────────┬──────────┐
│ INSTANCE INFO │ VCPU │ MEMORY GIB │ SAVINGS OVER ON-DEMAND │ FREQUENCY OF INTERRUPTION │ USD/HOUR │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ c6g.12xlarge │ 48 │ 96 │ 50% │ <5% │ 0.8113 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ c6g.16xlarge │ 64 │ 128 │ 50% │ <5% │ 1.0818 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ c6g.8xlarge │ 32 │ 64 │ 50% │ <5% │ 0.5409 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ m6g.12xlarge │ 48 │ 192 │ 54% │ <5% │ 0.8519 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ m6g.16xlarge │ 64 │ 256 │ 54% │ <5% │ 1.1358 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ m6g.4xlarge │ 16 │ 64 │ 54% │ <5% │ 0.284 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ m6g.8xlarge │ 32 │ 128 │ 54% │ <5% │ 0.5679 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ m6gd.8xlarge │ 32 │ 128 │ 61% │ <5% │ 0.5679 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.12xlarge │ 48 │ 384 │ 63% │ <5% │ 0.8924 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.16xlarge │ 64 │ 512 │ 63% │ <5% │ 1.1899 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.2xlarge │ 8 │ 64 │ 63% │ <5% │ 0.1487 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.4xlarge │ 16 │ 128 │ 63% │ <5% │ 0.2975 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.8xlarge │ 32 │ 256 │ 63% │ <5% │ 0.595 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6g.metal │ 64 │ 512 │ 63% │ <5% │ 1.1899 │
├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤
│ r6gd.4xlarge │ 16 │ 128 │ 68% │ 15-20% │ 0.2975 │
└───────────────┴──────┴────────────┴────────────────────────┴───────────────────────────┴──────────┘
Docker Image
The spotinfo
uses Docker both as a CI tool and for releasing the final spotinfo
Multi-Architecture Docker image (scratch
with updated ca-credentials
package).
Public Docker Image ghcr.io/alexei-led/spotinfo
docker pull ghcr.io/alexei-led/spotinfo:latest
Build Instructions
Makefile
The spotinfo
Makefile
is used for task automation only: compile, lint, test, etc. The project requires Go version 1.16+.
> make help
all Build program binary
check_deps Verify the system has all dependencies installed
test-bench Run benchmarks
test-short Run only short tests
test-verbose Run tests in verbose mode with coverage reporting
test-race Run tests with race detector
check test tests Run tests
test-xml Run tests with xUnit output
test-coverage Run coverage tests
lint Run golangci-lint
mockgen Run mockery to re/generate mocks for all interfaces
fmt Run gofmt on all source files
clean Cleanup everything
Continuous Integration
The GitHub action docker
is used for the spotinfo
CI.
Build with Docker
Use Docker buildx
plugin to build multi-architecture Docker image.
docker buildx build --platform=linux/arm64,linux/amd64 -t spotinfo -f Dockerfile .
Required GitHub secrets
Please specify the following GitHub secrets:
DOCKER_USERNAME
- Docker Registry usernameDOCKER_PASSWORD
- Docker Registry password or tokenCR_PAT
- Current GitHub Personal Access Token (withwrite/read
packages permission)DOCKER_REGISTRY
- optional; Docker Registry name, default todocker.io
DOCKER_REPOSITORY
- optional; Docker image repository name, default to$GITHUB_REPOSITORY
(i.e.user/repo
)
Additional secret to create GitHub Release:
RELEASE_TOKEN
- GitHub Personal Access Token (withrepo
scope)