Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltol committed Apr 24, 2024
2 parents 26d7915 + 2e9507b commit a1e6bb3
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 5 deletions.
7 changes: 7 additions & 0 deletions infracost-usage-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ resource_type_default_usage:
wd_queries: 11000
wd_custom_models: 4
wd_collections: 301
scc_evaluations: 1
data-science-experience_CAPACITY_UNIT_HOURS: 1
ibm_tg_gateway:
connection: 3
Expand Down Expand Up @@ -1325,6 +1326,12 @@ resource_usage:
wd_custom_models: 4 # Number of monthly custom models created; 3 included in the Enterprise plan; $500 for every additional custom model.
wd_collections: 301 # Number of monthly collections created; 300 included in the Enterprise plan. $500 for every additional 100 collections.

ibm_resource_instance.scc_standard:
scc_evaluations: 1

ibm_resource_instance.scc_trial:
scc_evaluations: 1

ibm_resource_instance.watson_studio_professional:
data-science-experience_CAPACITY_UNIT_HOURS: 1 # Amount of Capacity Unit-Hours used in a month

Expand Down
7 changes: 6 additions & 1 deletion internal/providers/terraform/ibm/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ var FreeResources = []string{
"ibm_is_vpc_address_prefix",
"ibm_is_vpn_gateway_connection",
"ibm_kms_key",
"ibm_kms_key_rings",
"ibm_kms_key_policies",
"ibm_kms_key_rings",
"ibm_pi_capture",
"ibm_pi_cloud_connection",
"ibm_pi_cloud_connection_network_attach",
Expand All @@ -118,11 +118,16 @@ var FreeResources = []string{
"ibm_resource_group",
"ibm_resource_key",
"ibm_scc_account_settings",
"ibm_scc_control_library",
"ibm_scc_instance_settings",
"ibm_scc_posture_collector",
"ibm_scc_posture_credential",
"ibm_scc_posture_profile_import",
"ibm_scc_posture_scan_initiate_validation",
"ibm_scc_posture_scope",
"ibm_scc_profile",
"ibm_scc_profile_attachment",
"ibm_scc_provider_type_instance",
"ibm_scc_rule",
"ibm_scc_rule_attachment",
"ibm_scc_template",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
├─ Instance 1 Instance $321.00
└─ Active Secrets 400 Secrets $86.00

ibm_resource_instance.scc_standard
└─ Evaluations 1,000 Evaluations $13.39

ibm_resource_instance.scc_trial
└─ Trial 1 $0.00

ibm_resource_instance.wa_instance_enterprise
├─ Instance (50000 MAU included) 1 Instance $6,000.00
├─ Additional Monthly Active Users 1 1K MAU $120.00
Expand Down Expand Up @@ -124,7 +130,7 @@
├─ Class 2 Resource Units 50 RU $0.09
└─ Class 3 Resource Units 50 RU $0.25

OVERALL TOTAL $15,461.16
OVERALL TOTAL $15,474.55
──────────────────────────────────
27 cloud resources were detected:
27 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
29 cloud resources were detected:
29 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ resource "ibm_resource_instance" "wa_instance_enterprise" {
resource_group_id = "default"
}

# Watson Discovery
resource "ibm_resource_instance" "watson_discovery_plus" {
name = "wd_plus"
service = "discovery"
Expand All @@ -201,6 +202,23 @@ resource "ibm_resource_instance" "watson_discovery_enterprise" {
resource_group_id = "default"
}

# Security and Compliance Center (SCC)
resource "ibm_resource_instance" "scc_standard" {
name = "scc_standard"
service = "compliance"
plan = "security-compliance-center-standard-plan"
location = "us-south"
resource_group_id = "default"
}

resource "ibm_resource_instance" "scc_trial" {
name = "scc_trial"
service = "compliance"
plan = "security-compliance-center-trial-plan"
location = "us-south"
resource_group_id = "default"
}

resource "ibm_resource_instance" "watson_studio_professional" {
name = "ws_professional"
service = "data-science-experience"
Expand All @@ -216,4 +234,3 @@ resource "ibm_resource_instance" "watson_studio_lite" {
location = "us-south"
resource_group_id = "default"
}

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ resource_usage:
wd_custom_models: 4 # Number of monthly custom models created; 3 included in the Enterprise plan; $500 for every additional custom model.
wd_collections: 301 # Number of monthly collections created; 300 included in the Enterprise plan. $500 for every additional 100 collections.

ibm_resource_instance.scc_standard:
scc_evaluations: 1000 # Large enough to make sure all decimals are correct

ibm_resource_instance.scc_trial:
scc_evaluations: 1000 # Large enough to make sure any potential cost will be picked up by the test

ibm_resource_instance.watson_studio_professional:
data-science-experience_CAPACITY_UNIT_HOURS: 1

Expand Down
4 changes: 4 additions & 0 deletions internal/resources/ibm/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ type ResourceInstance struct {
WD_Queries *float64 `infracost_usage:"wd_queries"`
WD_CustomModels *float64 `infracost_usage:"wd_custom_models"`
WD_Collections *float64 `infracost_usage:"wd_collections"`
// Security and Compliance Center (SCC)
SCC_Evaluations *float64 `infracost_usage:"scc_evaluations"`
// Watson Studio
WS_CUH *float64 `infracost_usage:"data-science-experience_CAPACITY_UNIT_HOURS"`
}
Expand Down Expand Up @@ -118,6 +120,7 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{
{Key: "wd_queries", DefaultValue: 0, ValueType: schema.Float64},
{Key: "wd_custom_models", DefaultValue: 0, ValueType: schema.Float64},
{Key: "wd_collections", DefaultValue: 0, ValueType: schema.Float64},
{Key: "scc_evaluations", DefaultValue: 0, ValueType: schema.Float64},
{Key: "data-science-experience_CAPACITY_UNIT_HOURS", DefaultValue: 1, ValueType: schema.Float64},
}

Expand All @@ -134,6 +137,7 @@ var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]R
"pm-20": GetWMLCostComponents,
"conversation": GetWACostComponents,
"discovery": GetWDCostComponents,
"compliance": GetSCCCostComponents,
"data-science-experience": GetWSCostComponents,
}

Expand Down
66 changes: 66 additions & 0 deletions internal/resources/ibm/resource_instance_scc.go
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"),
},
}
}

0 comments on commit a1e6bb3

Please sign in to comment.