|
|
@@ -158,6 +158,7 @@ var locationToRegion = map[string]string{
|
|
|
"US East (N. Virginia)": "us-east-1",
|
|
|
"US West (N. California)": "us-west-1",
|
|
|
"US West (Oregon)": "us-west-2",
|
|
|
+ "Asia Pacific (Hong Kong)": "ap-east-1",
|
|
|
"Asia Pacific (Mumbai)": "ap-south-1",
|
|
|
"Asia Pacific (Osaka-Local)": "ap-northeast-3",
|
|
|
"Asia Pacific (Seoul)": "ap-northeast-2",
|
|
|
@@ -172,11 +173,36 @@ var locationToRegion = map[string]string{
|
|
|
"EU (London)": "eu-west-2",
|
|
|
"EU (Paris)": "eu-west-3",
|
|
|
"EU (Stockholm)": "eu-north-1",
|
|
|
- "South America (São Paulo)": "sa-east-1",
|
|
|
+ "South America (Sao Paulo)": "sa-east-1",
|
|
|
"AWS GovCloud (US-East)": "us-gov-east-1",
|
|
|
"AWS GovCloud (US)": "us-gov-west-1",
|
|
|
}
|
|
|
|
|
|
+var regionToBillingRegionCode = map[string]string{
|
|
|
+ "us-east-2": "USE2",
|
|
|
+ "us-east-1": "",
|
|
|
+ "us-west-1": "USW1",
|
|
|
+ "us-west-2": "USW2",
|
|
|
+ "ap-east-1": "APE1",
|
|
|
+ "ap-south-1": "APS3",
|
|
|
+ "ap-northeast-3": "APN3",
|
|
|
+ "ap-northeast-2": "APN2",
|
|
|
+ "ap-southeast-1": "APS1",
|
|
|
+ "ap-southeast-2": "APS2",
|
|
|
+ "ap-northeast-1": "APN1",
|
|
|
+ "ca-central-1": "CAN1",
|
|
|
+ "cn-north-1": "",
|
|
|
+ "cn-northwest-1": "",
|
|
|
+ "eu-central-1": "EUC1",
|
|
|
+ "eu-west-1": "EU",
|
|
|
+ "eu-west-2": "EUW2",
|
|
|
+ "eu-west-3": "EUW3",
|
|
|
+ "eu-north-1": "EUN1",
|
|
|
+ "sa-east-1": "SAE1",
|
|
|
+ "us-gov-east-1": "UGE1",
|
|
|
+ "us-gov-west-1": "UGW1",
|
|
|
+}
|
|
|
+
|
|
|
// KubeAttrConversion maps the k8s labels for region to an aws region
|
|
|
func (aws *AWS) KubeAttrConversion(location, instanceType, operatingSystem string) string {
|
|
|
operatingSystem = strings.ToLower(operatingSystem)
|
|
|
@@ -489,7 +515,7 @@ func (aws *AWS) DownloadPricingData() error {
|
|
|
}
|
|
|
aws.ValidPricingKeys[key] = true
|
|
|
aws.ValidPricingKeys[spotKey] = true
|
|
|
- } else if strings.HasPrefix(product.Attributes.UsageType, "EBS:Volume") {
|
|
|
+ } else if strings.Contains(product.Attributes.UsageType, "EBS:Volume") {
|
|
|
key := locationToRegion[product.Attributes.Location] + "," + product.Attributes.UsageType
|
|
|
spotKey := key + ",preemptible"
|
|
|
pv := &PV{
|
|
|
@@ -546,15 +572,23 @@ func (aws *AWS) DownloadPricingData() error {
|
|
|
if ok {
|
|
|
aws.Pricing[key].OnDemand = offerTerm
|
|
|
aws.Pricing[spotKey].OnDemand = offerTerm
|
|
|
- if strings.HasSuffix(key, "EBS:VolumeP-IOPS.piops") {
|
|
|
+ if strings.Contains(key, "EBS:VolumeP-IOPS.piops") {
|
|
|
// If the specific UsageType is the per IO cost used on io1 volumes
|
|
|
// we need to add the per IO cost to the io1 PV cost
|
|
|
curr_region := strings.Split(key, ",")[0]
|
|
|
cost := offerTerm.PriceDimensions[sku.(string)+OnDemandRateCode+HourlyRateCode].PricePerUnit.USD
|
|
|
- cost_F, _ := strconv.ParseFloat(cost, 64)
|
|
|
- piops_key := curr_region + ",EBS:VolumeUsage.piops"
|
|
|
+ // UsageType in most regions starts with a region identifier
|
|
|
+ // Here we get that region identifier and then use it as part of
|
|
|
+ // the key for looking up and storing the per IO cost with the io1 price
|
|
|
+ billing_region_code := regionToBillingRegionCode[curr_region]
|
|
|
+ piops_key := ""
|
|
|
+ if billing_region_code != "" {
|
|
|
+ piops_key = curr_region + "," + billing_region_code + "-EBS:VolumeUsage.piops"
|
|
|
+ } else {
|
|
|
+ piops_key = curr_region + "," + "EBS:VolumeUsage.piops"
|
|
|
+ }
|
|
|
// Add the per IO cost to the PV object for the io1 volume type
|
|
|
- aws.Pricing[piops_key].PV.CostPerIO = strconv.FormatFloat(cost_F, 'f', -1, 64)
|
|
|
+ aws.Pricing[piops_key].PV.CostPerIO = cost
|
|
|
} else if strings.Contains(key, "EBS:Volume") {
|
|
|
// If volume, we need to get hourly cost and add it to the PV object
|
|
|
cost := offerTerm.PriceDimensions[sku.(string)+OnDemandRateCode+HourlyRateCode].PricePerUnit.USD
|