diff --git a/README.md b/README.md index c66f599..612d31f 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ brew install ec2-instance-selector #### Install w/ Curl for Linux/Mac ``` -curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/v2.3.0/ec2-instance-selector-`uname | tr '[:upper:]' '[:lower:]'`-amd64 && chmod +x ec2-instance-selector +curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/v2.3.2/ec2-instance-selector-`uname | tr '[:upper:]' '[:lower:]'`-amd64 && chmod +x ec2-instance-selector ``` To execute the CLI, you will need AWS credentials configured. Take a look at the [AWS CLI configuration documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#config-settings-and-precedence) for details on the various ways to configure credentials. An easy way to try out the ec2-instance-selector CLI is to populate the following environment variables with your AWS API credentials. diff --git a/go.mod b/go.mod index 388553c..cf39dfd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/aws/amazon-ec2-instance-selector/v2 go 1.18 require ( - github.com/aws/aws-sdk-go v1.43.31 + github.com/aws/aws-sdk-go v1.44.51 github.com/blang/semver/v4 v4.0.0 github.com/imdario/mergo v0.3.11 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index 53c0f70..475a643 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.43.31 h1:yJZIr8nMV1hXjAvvOLUFqZRJcHV7udPQBfhJqawDzI0= github.com/aws/aws-sdk-go v1.43.31/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go v1.44.51 h1:jO9hoLynZOrMM4dj0KjeKIK+c6PA+HQbKoHOkAEye2Y= +github.com/aws/aws-sdk-go v1.44.51/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= diff --git a/pkg/ec2pricing/ec2pricing_test.go b/pkg/ec2pricing/ec2pricing_test.go index f4dfbac..ee023ed 100644 --- a/pkg/ec2pricing/ec2pricing_test.go +++ b/pkg/ec2pricing/ec2pricing_test.go @@ -75,7 +75,7 @@ func setupMock(t *testing.T, api string, file string) mockedPricing { err = json.Unmarshal(mockFile, &productsMap) h.Assert(t, err == nil, "Error parsing mock json file contents "+mockFilename) productsOutput := pricing.GetProductsOutput{ - PriceList: []aws.JSONValue{productsMap}, + PriceList: []*string{aws.String(string(mockFile))}, } return mockedPricing{ GetProductsPagesResp: productsOutput, diff --git a/pkg/ec2pricing/odpricing.go b/pkg/ec2pricing/odpricing.go index f4ea64b..b62d154 100644 --- a/pkg/ec2pricing/odpricing.go +++ b/pkg/ec2pricing/odpricing.go @@ -225,10 +225,14 @@ func (c *OnDemandPricing) getRegionForPricingAPI() string { } // parseOndemandUnitPrice takes a priceList from the pricing API and parses its weirdness -func (c *OnDemandPricing) parseOndemandUnitPrice(priceList aws.JSONValue) (string, float64, error) { +func (c *OnDemandPricing) parseOndemandUnitPrice(priceDoc *string) (string, float64, error) { // TODO: this could probably be cleaned up a bit by adding a couple structs with json tags // We still need to some weird for-loops to get at elements under json keys that are IDs... // But it would probably be cleaner than this. + var priceList map[string]interface{} + if err := json.Unmarshal([]byte(*priceDoc), &priceList); err != nil { + return "", float64(-1.0), fmt.Errorf("unable to deserialize pricing doc") + } attributes, ok := priceList["product"].(map[string]interface{})["attributes"] if !ok { return "", float64(-1.0), fmt.Errorf("unable to find product attributes") diff --git a/pkg/selector/selector.go b/pkg/selector/selector.go index ebb10a0..4088d2d 100644 --- a/pkg/selector/selector.go +++ b/pkg/selector/selector.go @@ -132,6 +132,9 @@ func (itf Selector) Save() error { // Filter accepts a Filters struct which is used to select the available instance types // matching the criteria within Filters and returns a simple list of instance type strings +// +// Deprecated: This function will be replaced with GetFilteredInstanceTypes() and +// OutputInstanceTypes() in the next major version. func (itf Selector) Filter(filters Filters) ([]string, error) { outputFn := InstanceTypesOutputFn(outputs.SimpleInstanceTypeOutput) output, _, err := itf.FilterWithOutput(filters, outputFn) @@ -140,6 +143,9 @@ func (itf Selector) Filter(filters Filters) ([]string, error) { // FilterVerbose accepts a Filters struct which is used to select the available instance types // matching the criteria within Filters and returns a list instanceTypeInfo +// +// Deprecated: This function will be replaced with GetFilteredInstanceTypes() in the next +// major version. func (itf Selector) FilterVerbose(filters Filters) ([]*instancetypes.Details, error) { instanceTypeInfoSlice, err := itf.rawFilter(filters) if err != nil { @@ -151,6 +157,9 @@ func (itf Selector) FilterVerbose(filters Filters) ([]*instancetypes.Details, er // FilterWithOutput accepts a Filters struct which is used to select the available instance types // matching the criteria within Filters and returns a list of strings based on the custom outputFn +// +// Deprecated: This function will be replaced with GetFilteredInstanceTypes() and +// OutputInstanceTypes() in the next major version. func (itf Selector) FilterWithOutput(filters Filters, outputFn InstanceTypesOutput) ([]string, int, error) { instanceTypeInfoSlice, err := itf.rawFilter(filters) if err != nil {