From 69ef9dde66d50080bf1bc79c5d3d0017cdc6d304 Mon Sep 17 00:00:00 2001 From: "Rodrigo O.C. Pereira" <68402662+digocorbellini@users.noreply.github.com> Date: Wed, 15 Jun 2022 17:42:42 -0500 Subject: [PATCH] fixed issue with OD pricing for european regions (#132) * fixed issue with OD pricing for european regions * made string replacement more readable in getRegionForPricingAPI Co-authored-by: Rodrigo Okamoto --- pkg/ec2pricing/odpricing.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/ec2pricing/odpricing.go b/pkg/ec2pricing/odpricing.go index 3052191..f4ea64b 100644 --- a/pkg/ec2pricing/odpricing.go +++ b/pkg/ec2pricing/odpricing.go @@ -22,6 +22,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "time" "github.com/aws/aws-sdk-go/aws" @@ -214,6 +215,12 @@ func (c *OnDemandPricing) getRegionForPricingAPI() string { regionDescription = region.Description() } } + + // endpoints package returns European regions with the word "Europe," but the pricing API expects the word "EU." + // This formatting mismatch is only present with European regions. + // So replace "Europe" with "EU" if it exists in the regionDescription string. + regionDescription = strings.ReplaceAll(regionDescription, "Europe", "EU") + return regionDescription }