Skip to content

Commit 69ef9dd

Browse files
digocorbelliniRodrigo Okamoto
and
Rodrigo Okamoto
authored
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 <[email protected]>
1 parent de46c1f commit 69ef9dd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/ec2pricing/odpricing.go

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path/filepath"
2424
"strconv"
25+
"strings"
2526
"time"
2627

2728
"github.com/aws/aws-sdk-go/aws"
@@ -214,6 +215,12 @@ func (c *OnDemandPricing) getRegionForPricingAPI() string {
214215
regionDescription = region.Description()
215216
}
216217
}
218+
219+
// endpoints package returns European regions with the word "Europe," but the pricing API expects the word "EU."
220+
// This formatting mismatch is only present with European regions.
221+
// So replace "Europe" with "EU" if it exists in the regionDescription string.
222+
regionDescription = strings.ReplaceAll(regionDescription, "Europe", "EU")
223+
217224
return regionDescription
218225
}
219226

0 commit comments

Comments
 (0)