Skip to content

Commit

Permalink
Merge branch 'master' into fix/vpc-regions
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltol authored Apr 15, 2024
2 parents e1c07a3 + fd295c4 commit 137bfc4
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 128 deletions.
20 changes: 10 additions & 10 deletions infracost-usage-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1275,8 +1275,8 @@ resource_usage:
monthly_instance_hours: 730 # Monthly number of instance hours

ibm_resource_instance.resource_instance_kms:
kms_key_versions: 300 # Number of key versions managed per month
secretsmanager_active_secrets: 400 # Number of active secrets
kms_key_versions: 6 # Number of key versions managed per month
secretsmanager_active_secrets: 1 # Number of active secrets
secretsmanager_instance: 1 # Number of instances of secrets manager
appid_advanced_authentications: 20000 # Number of advanced authentications in a month
appid_authentications: 15000 # Number of simple authentications in a month
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resource "ibm_container_vpc_cluster" "cluster_without_usage" {
}

resource "ibm_container_vpc_cluster" "roks_cluster_with_usage" {
name = "mycluster-without-usage"
name = "myrokscluster-with-usage"
vpc_id = ibm_is_vpc.vpc1.id
flavor = "bx2.4x16"
worker_count = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ resource_usage:
ibm_container_vpc_cluster.cluster:
monthly_instance_hours: 730
ibm_is_vpc.vpc1:
gigabyte_transmitted_outbounds: 50100
gigabyte_transmitted_outbounds: 50100
ibm_container_vpc_cluster.roks_cluster_with_usage:
monthly_instance_hours: 730
7 changes: 7 additions & 0 deletions internal/providers/terraform/tftest/tftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var tfProviders = `
azurerm = {
source = "hashicorp/azurerm"
}
ibm = {
source = "IBM-Cloud/ibm"
}
}
}
Expand Down Expand Up @@ -70,6 +73,10 @@ var tfProviders = `
skip_provider_registration = true
features {}
}
provider "ibm" {
region = "us-south"
}
`

var (
Expand Down
116 changes: 0 additions & 116 deletions internal/resources/ibm/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
122 changes: 122 additions & 0 deletions internal/resources/ibm/resource_instance_sysdig-monitor.go
Original file line number Diff line number Diff line change
@@ -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),
}
}
}

0 comments on commit 137bfc4

Please sign in to comment.