{"id":17138354,"url":"https://github.com/alexei-led/spotinfo","last_synced_at":"2025-04-13T09:52:54.530Z","repository":{"id":41405351,"uuid":"353302047","full_name":"alexei-led/spotinfo","owner":"alexei-led","description":"CLI for exploring AWS EC2 Spot inventory. Inspect AWS Spot instance types, saving, price, and interruption frequency.","archived":false,"fork":false,"pushed_at":"2021-07-06T12:42:58.000Z","size":152,"stargazers_count":126,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T01:22:00.322Z","etag":null,"topics":["aws","aws-spot","aws-spot-cli","ec2-spot","spot-advisor","spot-instances"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexei-led.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-31T09:35:20.000Z","updated_at":"2025-03-19T23:41:38.000Z","dependencies_parsed_at":"2022-08-31T01:34:51.802Z","dependency_job_id":null,"html_url":"https://github.com/alexei-led/spotinfo","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexei-led%2Fspotinfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexei-led%2Fspotinfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexei-led%2Fspotinfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexei-led%2Fspotinfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexei-led","download_url":"https://codeload.github.com/alexei-led/spotinfo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695303,"owners_count":21146952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-spot","aws-spot-cli","ec2-spot","spot-advisor","spot-instances"],"created_at":"2024-10-14T20:09:24.652Z","updated_at":"2025-04-13T09:52:54.511Z","avatar_url":"https://github.com/alexei-led.png","language":"Go","funding_links":[],"categories":["📚 Projects (1974 total)","カテゴリ"],"sub_categories":["MCP Servers","☁️ \u003ca name=\"cloud--infrastructure\"\u003e\u003c/a\u003eクラウド・インフラ"],"readme":"[![docker](https://github.com/alexei-led/spotinfo/actions/workflows/build.yaml/badge.svg)](https://github.com/alexei-led/spotinfo/actions/workflows/build.yaml) [![Go Report Card](https://goreportcard.com/badge/github.com/alexei-led/spotinfo)](https://goreportcard.com/report/github.com/alexei-led/spotinfo) [![Docker Pulls](https://img.shields.io/docker/pulls/alexeiled/spotinfo.svg?style=popout)](https://hub.docker.com/r/alexeiled/spotinfo) [![](https://images.microbadger.com/badges/image/alexeiled/spotinfo.svg)](https://microbadger.com/images/alexeiled/spotinfo \"Get your own image badge on microbadger.com\") \n\n# spotinfo\n\nUsing [Amazon EC2 Spot](https://aws.amazon.com/ec2/spot/) instances is an excellent way to reduce EC2 on-demand instance cost, up to 90%. Whenever you have a workload that can survive VM interruption or be suspended and resumed later on without impacting business use cases, choosing the Spot pricing model is a no-brainer choice.\n\nYou 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.\n\nAmazon provides an excellent web interface [AWS Spot Instance Advisor](https://aws.amazon.com/ec2/spot/instance-advisor/) to explore available Spot instances and determine spot instance pools with the least chance of interruption. You can also check the savings you get over on-demand rates. You can also check the savings you get over on-demand rates. And then, you are supposed to use these metrics for selecting appropriate Spot instances.\n\nWhile the **AWS Spot Instance Advisor** is a valuable tool, it is not easy to use its data for scripting and automation, and some use cases require too many clicks.\n\nThat's why I created the `spotinfo` tool. It's an easy-to-use command-line tool (open source under Apache 2.0 License) that allows you to explore AWS Spot instances in a terminal and use the spot data it provides for scripting and automation.\n\nUnder the hood, the `spotinfo` is using two public data sources available from AWS:\n\n1. **AWS Spot Instance Advisor** [data feed](https://spot-bid-advisor.s3.amazonaws.com/spot-advisor-data.json)\n1. AWS Spot Pricing [data feed](http://spot-price.s3.amazonaws.com/spot.js)\n\n## Features\n\nThe `spotinfo` allows you to access the same information you can see in the **AWS Spot Instance Advisor**, but from a command line and can be used for scripting and automation use cases. In addition, the tool provides some useful features that are not available for **AWS Spot Instance Advisor** web interface.\n\n### Advanced Filtering\n\nThe first feature is _advanced filtering+. You can filter spot instances by:\n\n- vCPU - minimum number of CPU cores\n- Memory GiB - minimum memory size\n- Operating system - Linux or Windows\n- Region - one or more AWS regions (or `all` AWS regions)\n- Savings (compared to on-demand)\n- Frequency of interruption\n- Hourly rate (in `USD/hour`)\n\nWhen filtering by instance type, [regular expressions](https://github.com/google/re2/wiki/Syntax) are supported. And this can help you create advanced queries.\n\n### Spot Price Visibility\n\nWith **AWS Spot Instance Advisor**, you can see a discount comparing to the on-demand EC2 instance rate. But to find out, what is the actual price, you are going to pay, you must visit a different [AWS Spot pricing](https://aws.amazon.com/ec2/spot/pricing/) web page and search it again for the specific instance type.\n\nThe `spotinfo` saves your time and can display the spot price alongside other information. You can also filter and sort by spot price if you like.\n\n### Flexible Output Formats\n\nWorking with data in a command line and accessing data from scripts and automation requires flexibility of output format. The `spotinfo` can return results in multiple formats: human-friendly formats, like `table` and plain `text`, and automation-friendly: `json`, `csv`, or just a saving number. Choose whatever format you need for any concrete use case.\n\n### Compare Spots across multiple AWS Regions\n\nOne annoying thing about the **AWS Spot Instance Advisor**, is the inability to compare EC2 spot instances across multiple AWS regions. Only a single region view is available, or you need to open multiple browser tabs and constantly switch between them to compare spot instances across multiple AWS regions.\n\nThe `spotinfo` can help you to compare spot instances across multiple AWS regions. All you need to do is pass a `--region` command-line flag, and you can use this flag more than once.\n\nAnother option is to pass a special `all` value (with `--region=all` flag) to see spot instances across all available AWS regions.\n\n### Network Resilience\n\nWhile the `spotinfo` uses public AWS data feeds, it also embeds the same data within the tool. So, if data feed is not available, for any reason (no connectivity, service not available or other), the `spotinfo` still will be able to return the same result.\n\nData snapshoot from the both AWS data feeds is [embedded](https://golang.org/pkg/embed) into the `spotinfo` binary during the build.\n\n## Install\n\n### OS X with Homebrew\n\n```sh\nbrew tap alexei-led/spotinfo\nbrew install spotinfo\n```\n\n### Download platform binary\n\nDownload OS/platform specific binary from the [Releases](https://github.com/alexei-led/spotinfo/releases) page and add it to the `PATH`.\n\n- Supported OS: OS X, Windows, Linux\n- Supported Platforms: Intel (`amd64`) and ARM (`arm64`)\n\n## Usage\n\nWith `spotinfo` command you can get a filtered and sorted list of Spot instance types as a plain text, `JSON`, pretty table or `CSV` format.\n\n```shell\nspotinfo --help\nNAME:\n   spotinfo - spotinfo CLI\n\nUSAGE:\n   spotinfo [global options] command [command options] [arguments...]\n\nVERSION:\n   1.0.0\n\nCOMMANDS:\n   help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --type value    EC2 instance type (can be RE2 regexp patten)\n   --os value      instance operating system (windows/linux) (default: \"linux\")\n   --region value  set one or more AWS regions, use \"all\" for all AWS regions (default: \"us-east-1\")\n   --output value  format output: number|text|json|table|csv (default: \"table\")\n   --cpu value     filter: minimal vCPU cores (default: 0)\n   --memory value  filter: minimal memory GiB (default: 0)\n   --price value   filter: maximum price per hour (default: 0)\n   --sort value    sort results by interruption|type|savings|price|region (default: \"interruption\")\n   --order value   sort order asc|desc (default: \"asc\")\n   --help, -h      show help (default: false)\n   --version, -v   print the version (default: false)\n```\n\n## Data Sources\n\nThe `spotinfo` uses the following data sources to get updated information about AWS EC2 Spot instances:\n\n1. AWS Spot Advisor [JSON file](https://spot-bid-advisor.s3.amazonaws.com/spot-advisor-data.json), maintained/updated by AWS team\n2. AWS Spot Pricing [`callback` JS file](http://spot-price.s3.amazonaws.com/spot.js), maintained/updated by AWS team\n\nThe `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.\n\n### Examples\n\n#### Use Case 1\n\nGet all Graviton2 Linux Spot instances in the AWS Oregon (`us-west-2`) region, with CPU cores \u003e 8 and memory \u003e 64gb, sorted by type, and output the result in a table format.\n\n```shell\n# run binary\nspotinfo --type=\"^.(6g)(\\S)*\" --cpu=8 --memory=64 --region=us-west-2 --os=linux --output=table --sort=type\n\n# OR run Docker image\ndocker 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\n```\n\n##### Output\n\n```text\n┌───────────────┬──────┬────────────┬────────────────────────┬───────────────────────────┬──────────┐\n│ INSTANCE INFO │ VCPU │ MEMORY GIB │ SAVINGS OVER ON-DEMAND │ FREQUENCY OF INTERRUPTION │ USD/HOUR │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ c6g.12xlarge  │   48 │         96 │                    50% │ \u003c5%                       │   0.8113 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ c6g.16xlarge  │   64 │        128 │                    50% │ \u003c5%                       │   1.0818 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ c6g.8xlarge   │   32 │         64 │                    50% │ \u003c5%                       │   0.5409 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ m6g.12xlarge  │   48 │        192 │                    54% │ \u003c5%                       │   0.8519 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ m6g.16xlarge  │   64 │        256 │                    54% │ \u003c5%                       │   1.1358 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ m6g.4xlarge   │   16 │         64 │                    54% │ \u003c5%                       │    0.284 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ m6g.8xlarge   │   32 │        128 │                    54% │ \u003c5%                       │   0.5679 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ m6gd.8xlarge  │   32 │        128 │                    61% │ \u003c5%                       │   0.5679 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.12xlarge  │   48 │        384 │                    63% │ \u003c5%                       │   0.8924 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.16xlarge  │   64 │        512 │                    63% │ \u003c5%                       │   1.1899 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.2xlarge   │    8 │         64 │                    63% │ \u003c5%                       │   0.1487 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.4xlarge   │   16 │        128 │                    63% │ \u003c5%                       │   0.2975 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.8xlarge   │   32 │        256 │                    63% │ \u003c5%                       │    0.595 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6g.metal     │   64 │        512 │                    63% │ \u003c5%                       │   1.1899 │\n├───────────────┼──────┼────────────┼────────────────────────┼───────────────────────────┼──────────┤\n│ r6gd.4xlarge  │   16 │        128 │                    68% │ 15-20%                    │   0.2975 │\n└───────────────┴──────┴────────────┴────────────────────────┴───────────────────────────┴──────────┘\n```\n\n#### Use Case 2\n\nCompare `m5a.xlarge` Linux Spot instances across 3 AWS regions, sorted by price. Output the result in a `JSON` format.\n\n```shell\nspotinfo --type=\"m5a.xlarge\" --output=json --sort=price --order=asc --region=us-west-1 --region=us-east-1 --region=ap-south-1\n```\n\n##### Output\n\n```json\n[\n  {\n    \"Region\": \"ap-south-1\",\n    \"Instance\": \"m5a.xlarge\",\n    \"Range\": {\n      \"label\": \"\u003c5%\",\n      \"min\": 0,\n      \"max\": 5\n    },\n    \"Savings\": 50,\n    \"Info\": {\n      \"cores\": 4,\n      \"emr\": true,\n      \"ram_gb\": 16\n    },\n    \"Price\": 0.0554\n  },\n  {\n    \"Region\": \"us-west-1\",\n    \"Instance\": \"m5a.xlarge\",\n    \"Range\": {\n      \"label\": \"\u003c5%\",\n      \"min\": 0,\n      \"max\": 5\n    },\n    \"Savings\": 65,\n    \"Info\": {\n      \"cores\": 4,\n      \"emr\": true,\n      \"ram_gb\": 16\n    },\n    \"Price\": 0.0715\n  },\n  {\n    \"Region\": \"us-east-1\",\n    \"Instance\": \"m5a.xlarge\",\n    \"Range\": {\n      \"label\": \"\u003c5%\",\n      \"min\": 0,\n      \"max\": 5\n    },\n    \"Savings\": 56,\n    \"Info\": {\n      \"cores\": 4,\n      \"emr\": true,\n      \"ram_gb\": 16\n    },\n    \"Price\": 0.0759\n  }\n]\n```\n\n## Docker Image\n\nThe `spotinfo` uses Docker both as a CI tool and for releasing the final `spotinfo` Multi-Architecture Docker image (`scratch` with updated `ca-credentials` package).\n\nPublic Docker Image [ghcr.io/alexei-led/spotinfo](https://github.com/users/alexei-led/packages/container/package/spotinfo)\n\n```shell\ndocker pull ghcr.io/alexei-led/spotinfo:latest\n```\n\n## Build Instructions\n\n### Makefile\n\nThe `spotinfo` `Makefile` is used for task automation only: compile, lint, test, etc.\nThe project requires Go version 1.16+.\n\n```text\n\u003e make help\nall              Build program binary\ncheck_deps       Verify the system has all dependencies installed\ntest-bench       Run benchmarks\ntest-short       Run only short tests\ntest-verbose     Run tests in verbose mode with coverage reporting\ntest-race        Run tests with race detector\ncheck test tests Run tests\ntest-xml         Run tests with xUnit output\ntest-coverage    Run coverage tests\nlint             Run golangci-lint\nmockgen          Run mockery to re/generate mocks for all interfaces\nfmt              Run gofmt on all source files\nclean            Cleanup everything\n```\n\n### Continuous Integration\n\nThe GitHub action `docker` is used for the `spotinfo` CI.\n\n### Build with Docker\n\nUse Docker `buildx` plugin to build multi-architecture Docker image.\n\n```sh\ndocker buildx build --platform=linux/arm64,linux/amd64 -t spotinfo -f Dockerfile .\n```\n\n#### Required GitHub secrets\n\nPlease specify the following GitHub secrets:\n\n1. `DOCKER_USERNAME` - Docker Registry username\n1. `DOCKER_PASSWORD` - Docker Registry password or token\n1. `CR_PAT` - Current GitHub Personal Access Token (with `write/read` packages permission)\n1. `DOCKER_REGISTRY` - _optional_; Docker Registry name, default to `docker.io`\n1. `DOCKER_REPOSITORY` - _optional_; Docker image repository name, default to `$GITHUB_REPOSITORY` (i.e. `user/repo`)\n\nAdditional secret to create GitHub Release:\n\n1. `RELEASE_TOKEN` - GitHub Personal Access Token (with `repo` scope)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexei-led%2Fspotinfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexei-led%2Fspotinfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexei-led%2Fspotinfo/lists"}