forked from infracost/infracost
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Security Compliance Center (SCC) (#166)
* Create new resource_instance file for 'compliance' (SCC) sevice * Create cost components * Add example usage units * Add resource instance variables * Write TF tests * Add usage units for tests * Update test golden file with SCC results * Fix Watson Assistant usage units variable name * Add free SCC resources
- Loading branch information
1 parent
3c4eda8
commit 2e9507b
Showing
7 changed files
with
120 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package ibm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/infracost/infracost/internal/schema" | ||
"github.com/shopspring/decimal" | ||
) | ||
|
||
const STANDARD_PLAN_PROGRAMMATIC_NAME string = "security-compliance-center-standard-plan" | ||
const TRIAL_PLAN_PROGRAMMATIC_NAME string = "security-compliance-center-trial-plan" | ||
|
||
func GetSCCCostComponents(r *ResourceInstance) []*schema.CostComponent { | ||
if r.Plan == STANDARD_PLAN_PROGRAMMATIC_NAME { | ||
return []*schema.CostComponent{ | ||
SCCMonthlyEvaluationsCostComponent(r), | ||
} | ||
} else if r.Plan == TRIAL_PLAN_PROGRAMMATIC_NAME { | ||
costComponent := schema.CostComponent{ | ||
Name: "Trial", | ||
UnitMultiplier: decimal.NewFromInt(1), | ||
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), | ||
} | ||
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) | ||
return []*schema.CostComponent{ | ||
&costComponent, | ||
} | ||
} else { | ||
costComponent := schema.CostComponent{ | ||
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan), | ||
UnitMultiplier: decimal.NewFromInt(1), // Final quantity for this cost component will be divided by this amount | ||
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), | ||
} | ||
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) | ||
return []*schema.CostComponent{ | ||
&costComponent, | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* Evaluations: | ||
* - Standard: $USD/evaluation/month | ||
*/ | ||
func SCCMonthlyEvaluationsCostComponent(r *ResourceInstance) *schema.CostComponent { | ||
|
||
var quantity *decimal.Decimal = decimalPtr(decimal.NewFromFloat(*r.SCC_Evaluations)) // Quantity of current cost component (i.e. Number of evaluations performed in a month) | ||
|
||
return &schema.CostComponent{ | ||
Name: "Evaluations", | ||
Unit: "Evaluations", | ||
UnitMultiplier: decimal.NewFromFloat(1), // Final quantity for this cost component will be divided by this amount | ||
MonthlyQuantity: quantity, | ||
ProductFilter: &schema.ProductFilter{ | ||
VendorName: strPtr("ibm"), | ||
Region: strPtr(r.Location), | ||
Service: &r.Service, | ||
AttributeFilters: []*schema.AttributeFilter{ | ||
{Key: "planName", Value: &r.Plan}, | ||
}, | ||
}, | ||
PriceFilter: &schema.PriceFilter{ | ||
Unit: strPtr("EVALUATION"), | ||
}, | ||
} | ||
} |