Skip to content

Commit

Permalink
AWS Reserved Instances Recommendation Currency Conversion Fix (#1540)
Browse files Browse the repository at this point in the history
* fix

* fix
  • Loading branch information
XOmniverse authored Oct 12, 2023
1 parent 2c67a03 commit 50bcf49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cost/aws/reserved_instances/recommendations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3.1

- Fixed issue where policy would fail to do proper currency conversion

## v3.0

- Policy now automatically converts savings to local currency when appropriate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ severity "medium"
category "Cost"
default_frequency "weekly"
info(
version: "3.0",
version: "3.1",
provider: "AWS",
service: "Compute",
policy_set: "Reserved Instances",
Expand Down Expand Up @@ -458,11 +458,11 @@ script "js_currency", type:"javascript" do
result = ds_currency_target
result['exchange_rate'] = 1
if (ds_currency_conversion['to'] != undefined) {
if (ds_currency_conversion[0]['to'] != undefined) {
currency_code = ds_currency_target['code']
current_month = parseInt(new Date().toISOString().split('-')[1])
conversion_block = _.find(ds_currency_conversion['to'][currency_code], function(item) {
conversion_block = _.find(ds_currency_conversion[0]['to'][currency_code], function(item) {
return item['month'] == current_month
})
Expand Down Expand Up @@ -605,14 +605,14 @@ script "js_ri_normalization", type: "javascript" do
conversion_message = ""
if (ds_currency['code'] != currency && ds_currency_conversion['to'] != undefined && exchange_rate != 1) {
if (ds_currency['code'] != currency && ds_currency_conversion.length > 0 && exchange_rate != 1) {
conversion_message = [
"Savings values were converted from ", currency, " to ", ds_currency['code'],
" using an exchange rate of ", exchange_rate, ".\n\n"
].join('')
}
if (ds_currency['code'] != currency && ds_currency_conversion['to'] == undefined) {
if (ds_currency['code'] != currency && ds_currency_conversion.length == 0) {
conversion_message = "Savings values are in ", currency, " due to a malfunction with Flexera's internal currency conversion API. Please contact Flexera support to report this issue."
}
Expand Down

0 comments on commit 50bcf49

Please sign in to comment.