Categorygithub.com/LeanerCloud/ec2-instances-info
modulepackage
0.0.0-20241101103313-93438b48d82f
Repository: https://github.com/leanercloud/ec2-instances-info.git
Documentation: pkg.go.dev

# README

ec2-instances-info

Build Status Go Report Card GoDoc

Golang library providing specs and pricing information about AWS resources such as EC2 instances, RDS databases, ElastiCache and OpenSearch clusters.

It is based on the data that is also powering the comprehensive www.ec2instances.info instance comparison website, but made easier to consume from Go software.

This code is offered under the public domain/unlicense, but we also offer an API that automates data updates, available for a monthly subscription that helps support ongoing development of this library.

Reach out to us on Slack if you're interested in API access.

History

This used to be a part of my other project AutoSpotting which uses it intensively, but I decided to extract it into a dedicated project since it may be useful to someone else out there.

Some data fields that were not needed in AutoSpotting may not yet be exposed but they can be added upon demand.

Installation or update

You will need Go 1.16 or latest, then it's a matter of installing it as usual using go get

go get -u github.com/LeanerCloud/ec2-instances-info/...

Usage

One-off usage, with static data

import "github.com/LeanerCloud/ec2-instances-info"

data, err := ec2instancesinfo.Data() // only needed once

// This would print all the available instance type names:
for _, i := range *data {
  fmt.Println("Instance type", i.InstanceType)
}

See the examples directory for a working code example.

One-off usage, with updated instance type data

import "github.com/LeanerCloud/ec2-instances-info"

key := "API_KEY" // API keys are available upon demand from [email protected], free of charge for personal use

err:= ec2instancesinfo.UpdateData(nil, &key);
if err!= nil{
   fmt.Println("Couldn't update instance type data, reverting to static compile-time data", err.Error())
}

data, err := ec2instancesinfo.Data() // needs to be called once after data updates

// This would print all the available instance type names:
for _, i := range *data {
  fmt.Println("Instance type", i.InstanceType)
}

Continuous usage, with instance type data updated every 2 days

import "github.com/LeanerCloud/ec2-instances-info"

key := "API_KEY"
go ec2instancesinfo.Updater(2, nil, &key); // use 0 or negative values for weekly updates

data, err := ec2instancesinfo.Data() // only needed once

// This would print all the available instance type names:
for _, i := range *data {
  fmt.Println("Instance type", i.InstanceType)
}

Contributing

Pull requests and feedback are welcome.

The data can be updated for new instance type coverage by running make.

Try it out on GCP Cloud Shell

  • Open in Cloud Shell

  • Click on the Terminal then New Terminal in the top menu

  • In the terminal run cd ~/cloudshell_open/ec2-instances-info/examples/instances/

  • go run . will run the example code.

# Packages

No description provided by the author

# Functions

Data generates the InstanceData object based on data sourced from ec2instances.info.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

ElastiCacheInstance represents the structure of each JSON object in the array.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PricingDetail represents the pricing information for each term.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RegionPricing represents the pricing information for each region.
No description provided by the author
No description provided by the author
ServicePricing represents the pricing for a particular service (e.g., Memcached, Redis, Valkey).
No description provided by the author

# Type aliases

No description provided by the author
InstanceData is a large data structure containing pricing and specs information about all the EC2 instance types from all AWS regions.
No description provided by the author
No description provided by the author
No description provided by the author