ec2instancesinfo

package module
v0.0.0-...-4533564 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: MIT, Unlicense Imports: 6 Imported by: 0

README

ec2-instances-info

Build Status Go Report Card GoDoc

Golang library providing specs and pricing information about AWS EC2 instances, based on the data that is also powering the comprehensive www.ec2instances.info instance comparison website.

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

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

Usage

import "github.com/cristim/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.

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceData

type InstanceData []jsonInstance

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

func Data

func Data() (*InstanceData, error)

Data generates the InstanceData object based on data sourced from ec2instances.info. The data is available there as a JSON blob, which is converted into golang source-code by the go-bindata tool and unmarshaled into a golang data structure by this library.

type Pricing

type Pricing struct {
	OnDemand float64  `json:"ondemand,string"`
	SpotMin  float64  `json:"spot_min,string"`
	SpotMax  float64  `json:"spot_max,string"`
	Reserved Reserved `json:"reserved"`
}

type RegionPrices

type RegionPrices struct {
	Linux              Pricing `json:"linux"`
	LinuxSQL           Pricing `json:"linuxSQL"`
	LinuxSQLEnterprise Pricing `json:"linuxSQLEnterprise"`
	LinuxSQLWeb        Pricing `json:"linuxSQLWeb"`
	MSWin              Pricing `json:"mswin"`
	MSWinSQL           Pricing `json:"mswinSQL"`
	MSWinSQLEnterprise Pricing `json:"mswinSQLEnterprise"`
	MSWinSQLWeb        Pricing `json:"mswinSQLWeb"`
	RHEL               Pricing `json:"rhel"`
	SLES               Pricing `json:"sles"`
	EBSSurcharge       float64 `json:"ebs,string"`
}

type Reserved

type Reserved struct {
	StandardNoUpfront1Year          float64 `json:"yrTerm1Standard.noUpfront,string"`
	StandardNoUpfront3Years         float64 `json:"yrTerm3Standard.noUpfront,string"`
	StandardPartiallUpfront1Year    float64 `json:"yrTerm1Standard.partialUpfront,string"`
	StandardPartialUpfront3Years    float64 `json:"yrTerm3Standard.partialUpfront,string"`
	StandardAllUpfront1Year         float64 `json:"yrTerm1Standard.allUpfront,string"`
	StandardAllUpfront3Years        float64 `json:"yrTerm3Standard.allUpfront,string"`
	ConvertibleNoUpfront1Year       float64 `json:"yrTerm1Convertible.noUpfront,string"`
	ConvertibleNoUpfront3Years      float64 `json:"yrTerm3Convertible.noUpfront,string"`
	ConvertiblePartiallUpfront1Year float64 `json:"yrTerm1Convertible.partialUpfront,string"`
	ConvertiblePartialUpfront3Years float64 `json:"yrTerm3Convertible.partialUpfront,string"`
	ConvertibleAllUpfront1Year      float64 `json:"yrTerm1Convertible.allUpfront,string"`
	ConvertibleAllUpfront3Years     float64 `json:"yrTerm3Convertible.allUpfront,string"`
}

type StorageConfiguration

type StorageConfiguration struct {
	SSD     bool    `json:"ssd"`
	Devices int     `json:"devices"`
	Size    float32 `json:"size"`
	NVMeSSD bool    `json:"nvme_ssd"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL