From 15f25156f955e0eec5721e586c28ad5e903e2e4a Mon Sep 17 00:00:00 2001 From: "hlem@ca.ibm.com" Date: Fri, 5 Apr 2024 14:05:30 -0400 Subject: [PATCH] update defaults --- infracost-usage-example.yml | 16 +-- internal/resources/ibm/resource_instance.go | 116 ----------------- .../ibm/resource_instance_sysdig-monitor.go | 122 ++++++++++++++++++ 3 files changed, 130 insertions(+), 124 deletions(-) create mode 100644 internal/resources/ibm/resource_instance_sysdig-monitor.go diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index 1d909531aee..f0e8e97fcc1 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -59,10 +59,10 @@ resource_type_default_usage: secretsmanager_instance: 1 logdna_gigabyte_months: 1 activitytracker_gigabyte_months: 1 - monitoring_node_hour: 1 - monitoring_container_hour: 1 - monitoring_api_call: 1 - monitoring_timeseries_hour: 1 + monitoring_node_hour: 700 + monitoring_container_hour: 700 + monitoring_api_call: 1000 + monitoring_timeseries_hour: 1000 continuousdelivery_authorized_users: 1 wml_capacity_unit_hour: 20 wml_instance: 1 @@ -1286,10 +1286,10 @@ resource_usage: appconnect_vcpu_hours: 10 # The number of VCPU hours used in a month logdna_gigabyte_months: 10 # The amount of logs in a month in GB activitytracker_gigabyte_months: 10 # The amount of logs in a month in GB - monitoring_node_hour: 730 # The amount of hours monitoring runs on a host in a month - monitoring_container_hour: 1460 # Additional containers on a host above the base 50 - monitoring_api_call: 100000 # Additional API calls above the base 1M/instance - monitoring_timeseries_hour: 100 # Additional time-series cost above the base 1000/host + monitoring_node_hour: 700 # The amount of hours monitoring runs on a host in a month + monitoring_container_hour: 700 # Additional containers on a host above the base 50 + monitoring_api_call: 1000 # Additional API calls above the base 1M/instance + monitoring_timeseries_hour: 1000 # Additional time-series cost above the base 1000/host continuousdelivery_authorized_users: 10 # Number of authorized users to the CD instance and its managed toolchains wml_capacity_unit_hour: 20 # Amount of Capacity Unit-Hours used in a month wml_instance: 1 # The number of instances used per month where each instance includes 2500 CUHs diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 222f88521fa..7ae708d4897 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -492,122 +492,6 @@ func GetLogDNACostComponents(r *ResourceInstance) []*schema.CostComponent { } } -func GetSysdigTimeseriesCostComponent(r *ResourceInstance) *schema.CostComponent { - var q *decimal.Decimal - if r.Monitoring_TimeSeriesHour != nil { - q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_TimeSeriesHour)) - } - return &schema.CostComponent{ - Name: "Additional Time series", - Unit: "Time series hour", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: q, - 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("TIME_SERIES_HOURS"), - }, - } -} - -func GetSysdigContainerCostComponent(r *ResourceInstance) *schema.CostComponent { - var q *decimal.Decimal - if r.Monitoring_ContainerHour != nil { - q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_ContainerHour)) - } - return &schema.CostComponent{ - Name: "Additional Containers", - Unit: "Container Hours", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: q, - 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("CONTAINER_HOURS"), - }, - } -} - -func GetSysdigApiCallCostComponent(r *ResourceInstance) *schema.CostComponent { - var q *decimal.Decimal - if r.Monitoring_APICall != nil { - q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_APICall)) - } - return &schema.CostComponent{ - Name: "Additional API Calls", - Unit: "API Calls", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: q, - 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("API_CALL_HOURS"), - }, - } -} - -func GetSysdigNodeHourCostComponent(r *ResourceInstance) *schema.CostComponent { - var q *decimal.Decimal - if r.Monitoring_NodeHour != nil { - q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_NodeHour)) - } - return &schema.CostComponent{ - Name: "Base Node Hour", - Unit: "Node Hours", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: q, - 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("NODE_HOURS"), - }, - } -} - -func GetSysdigCostComponenets(r *ResourceInstance) []*schema.CostComponent { - - if r.Plan == "lite" { - costComponent := &schema.CostComponent{ - Name: "Lite plan", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), - } - costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) - return []*schema.CostComponent{costComponent} - } else { - return []*schema.CostComponent{ - GetSysdigTimeseriesCostComponent(r), - GetSysdigContainerCostComponent(r), - GetSysdigApiCallCostComponent(r), - GetSysdigNodeHourCostComponent(r), - } - } -} - func GetActivityTrackerCostComponents(r *ResourceInstance) []*schema.CostComponent { var q *decimal.Decimal if r.ActivityTracker_GigabyteMonths != nil { diff --git a/internal/resources/ibm/resource_instance_sysdig-monitor.go b/internal/resources/ibm/resource_instance_sysdig-monitor.go new file mode 100644 index 00000000000..e9ff57b7644 --- /dev/null +++ b/internal/resources/ibm/resource_instance_sysdig-monitor.go @@ -0,0 +1,122 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +func GetSysdigTimeseriesCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.Monitoring_TimeSeriesHour != nil { + q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_TimeSeriesHour)) + } + return &schema.CostComponent{ + Name: "Additional Time series", + Unit: "Time series hour", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: q, + 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("TIME_SERIES_HOURS"), + }, + } +} + +func GetSysdigContainerCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.Monitoring_ContainerHour != nil { + q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_ContainerHour)) + } + return &schema.CostComponent{ + Name: "Additional Container Hours", + Unit: "Container Hours", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: q, + 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("CONTAINER_HOURS"), + }, + } +} + +func GetSysdigApiCallCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.Monitoring_APICall != nil { + q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_APICall)) + } + return &schema.CostComponent{ + Name: "Additional API Calls", + Unit: "API Calls", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: q, + 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("API_CALL_HOURS"), + }, + } +} + +func GetSysdigNodeHourCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.Monitoring_NodeHour != nil { + q = decimalPtr(decimal.NewFromFloat(*r.Monitoring_NodeHour)) + } + return &schema.CostComponent{ + Name: "Node Hours", + Unit: "Node Hours", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: q, + 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("NODE_HOURS"), + }, + } +} + +func GetSysdigCostComponenets(r *ResourceInstance) []*schema.CostComponent { + + if r.Plan == "lite" { + costComponent := &schema.CostComponent{ + Name: "Lite plan", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + return []*schema.CostComponent{costComponent} + } else { + return []*schema.CostComponent{ + GetSysdigTimeseriesCostComponent(r), + GetSysdigContainerCostComponent(r), + GetSysdigApiCallCostComponent(r), + GetSysdigNodeHourCostComponent(r), + } + } +}