Skip to content

Commit

Permalink
Merge pull request #226 from IBM-Cloud/fix/productfilter
Browse files Browse the repository at this point in the history
Fix missing `ProductFilter` property from some supported resources
  • Loading branch information
luisarojas authored Nov 7, 2024
2 parents f83a058 + 94aeaa2 commit 31e2e35
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name Monthly Qty Unit Monthly Cost

ibm_cos_bucket.accelerated-archive-us-south
├─ Accelerated Archive Capacity Monthly cost depends on usage: $0.00418 per GB
├─ Accelerated Archive Capacity Monthly cost depends on usage: $0.005225 per GB
├─ Accelerated Archive Restore Monthly cost depends on usage: $0.0418 per GB
├─ Storage Capacity (first 499999 GB) Monthly cost depends on usage: $0.02299 per GB
├─ Storage Capacity (over 499999 GB) Monthly cost depends on usage: $0.0209 per GB
Expand All @@ -13,7 +13,7 @@
└─ Public Standard Egress (over 150000 GB) Monthly cost depends on usage: $0.05 per GB

ibm_cos_bucket.archive-us-south
├─ Archive Capacity 1,000 GB $1.03
├─ Archive Capacity 1,000 GB $1.30
├─ Archive Restore 1,000 GB $20.90
├─ Storage Capacity (first 499999 GB) Monthly cost depends on usage: $0.02299 per GB
├─ Storage Capacity (over 499999 GB) Monthly cost depends on usage: $0.0209 per GB
Expand Down Expand Up @@ -93,7 +93,7 @@
└─ Public Standard Egress (next 100000 GB) 0 GB $0.00
└─ Public Standard Egress (over 150000 GB) 0 GB $0.00

OVERALL TOTAL $495.12
OVERALL TOTAL $495.39
──────────────────────────────────
14 cloud resources were detected:
∙ 13 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
└─ Lite plan 1 $0.00

ibm_resource_instance.resource_instance_power_iaas
└─ test 1 Instance $0.00
└─ Workspace for Power Virtual Server 1 Workspace $0.00

ibm_resource_instance.resource_instance_secrets_manager
├─ Instance 1 Instance $321.00
Expand Down
8 changes: 8 additions & 0 deletions internal/resources/ibm/ibm_cos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,14 @@ func (r *IbmCosBucket) LitePlanCostComponent() *schema.CostComponent {
Unit: "Instance",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: strPtr(("cloud-object-storage")),
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return &costComponent
Expand Down
77 changes: 70 additions & 7 deletions internal/resources/ibm/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,17 @@ func GetSecretsManagerCostComponents(r *ResourceInstance) []*schema.CostComponen
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan: %s", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand All @@ -327,13 +335,20 @@ func GetSecretsManagerCostComponents(r *ResourceInstance) []*schema.CostComponen
}

func GetPowerCostComponents(r *ResourceInstance) []*schema.CostComponent {
q := decimalPtr(decimal.NewFromInt(1))

costComponent := schema.CostComponent{
Name: r.Name,
Unit: "Instance",
Name: "Workspace for Power Virtual Server",
Unit: "Workspace",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: q,
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down Expand Up @@ -425,9 +440,17 @@ func GetAppIDCostComponents(r *ResourceInstance) []*schema.CostComponent {
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan: %s", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down Expand Up @@ -525,16 +548,32 @@ func GetAppConnectCostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
&costComponent,
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand All @@ -553,6 +592,14 @@ func GetLogDNACostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down Expand Up @@ -589,6 +636,14 @@ func GetActivityTrackerCostComponents(r *ResourceInstance) []*schema.CostCompone
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{costComponent}
Expand Down Expand Up @@ -623,6 +678,14 @@ func GetContinuousDeliveryCostComponenets(r *ResourceInstance) []*schema.CostCom
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{costComponent}
Expand Down
18 changes: 17 additions & 1 deletion internal/resources/ibm/resource_instance_aiopenscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,30 @@ func GetWGOVCostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{costComponent}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
26 changes: 25 additions & 1 deletion internal/resources/ibm/resource_instance_conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func GetWACostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand All @@ -41,16 +49,32 @@ func GetWACostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Trial",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
&costComponent,
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
10 changes: 9 additions & 1 deletion internal/resources/ibm/resource_instance_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ func GetWDCostComponents(r *ResourceInstance) []*schema.CostComponent {
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1), // Final quantity for this cost component will be divided by this amount
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
10 changes: 9 additions & 1 deletion internal/resources/ibm/resource_instance_dns-svcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ func GetDNSServicesCostComponents(r *ResourceInstance) []*schema.CostComponent {
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1), // Final quantity for this cost component will be divided by this amount
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
18 changes: 17 additions & 1 deletion internal/resources/ibm/resource_instance_messagehub.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,30 @@ func GetEventStreamsCostComponents(r *ResourceInstance) []*schema.CostComponent
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{costComponent}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
18 changes: 17 additions & 1 deletion internal/resources/ibm/resource_instance_pm20.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,32 @@ func GetWMLCostComponents(r *ResourceInstance) []*schema.CostComponent {
Name: "Lite plan",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
&costComponent,
}
} else {
costComponent := schema.CostComponent{
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan),
Name: fmt.Sprintf("Plan %s not found", r.Plan),
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Region: strPtr(r.Location),
Service: &r.Service,
AttributeFilters: []*schema.AttributeFilter{
{Key: "planName", Value: &r.Plan},
},
},
}
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0)))
return []*schema.CostComponent{
Expand Down
Loading

0 comments on commit 31e2e35

Please sign in to comment.