From efa54fa6e1292f216140a1b73fba5c3e0a9c4e97 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Tue, 16 Apr 2024 17:01:16 -0400 Subject: [PATCH 01/10] Create new file for resource_instance type aiopenscale (watsonx.governance) --- internal/resources/ibm/resource_instance_ aiopenscale.go | 1 + 1 file changed, 1 insertion(+) create mode 100644 internal/resources/ibm/resource_instance_ aiopenscale.go diff --git a/internal/resources/ibm/resource_instance_ aiopenscale.go b/internal/resources/ibm/resource_instance_ aiopenscale.go new file mode 100644 index 00000000000..00081686020 --- /dev/null +++ b/internal/resources/ibm/resource_instance_ aiopenscale.go @@ -0,0 +1 @@ +package ibm From fc371aaf54ac754970f0ad163ba98e349ead4a84 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Wed, 17 Apr 2024 19:11:09 -0400 Subject: [PATCH 02/10] Update golangci-lint-action version in GitHub Actions --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0809b7f366a..4150f7254ad 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,10 +19,10 @@ jobs: go-version: 1.19 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v2.5.2 + uses: golangci/golangci-lint-action@v2.297.0 with: - # Required: the version of golangci-lint is required and must be specified without patch version: they always use the latest patch version. - version: v1.45 + version: latest + skip-pkg-cache: true args: --timeout 3m0s - name: Install Terragrunt v0.31.8 From bf286f8f3b136c17810e7348b560ab1a94ffceaf Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Thu, 18 Apr 2024 09:25:43 -0400 Subject: [PATCH 03/10] Add func call & resource parameters for service watsonx.gov --- internal/resources/ibm/resource_instance.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 7ae708d4897..2a333c592d4 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -64,6 +64,12 @@ type ResourceInstance struct { WML_Class1RU *float64 `infracost_usage:"wml_class1_ru"` WML_Class2RU *float64 `infracost_usage:"wml_class2_ru"` WML_Class3RU *float64 `infracost_usage:"wml_class3_ru"` + // watsonx.gov + // https://dataplatform.cloud.ibm.com/docs/content/svc-welcome/aiopenscale.html?context=cpdaas&audience=wdp + WGOV_PredictiveModelEvals *float64 `infracost_usage:"wgov_predictive_model_evaluation"` + WGOV_FoundationalModelEvals *float64 `infracost_usage:"wgov_foundational_model_evaluation"` + WGOV_GlobalExplanations *float64 `infracost_usage:"wgov_global_explanation"` + WGOV_LocalExplanations *float64 `infracost_usage:"wgov_local_explanation"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -111,6 +117,7 @@ var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]R "sysdig-monitor": GetSysdigCostComponenets, "continuous-delivery": GetContinuousDeliveryCostComponenets, "pm-20": GetWMLCostComponents, + "aiopenscale": GetWGOVCostComponents, } func KMSKeyVersionsFreeCostComponent(r *ResourceInstance) *schema.CostComponent { From a146bcf61183c5ec519b88077abcbb3a9d721ba5 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Thu, 18 Apr 2024 09:27:07 -0400 Subject: [PATCH 04/10] Add usage for wgov units --- infracost-usage-example.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index 4160ace0e7d..554fec01444 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -69,6 +69,10 @@ resource_type_default_usage: wml_class1_ru: 20 wml_class2_ru: 20 wml_class3_ru: 20 + wgov_predictive_model_evaluation: 1 + wgov_foundational_model_evaluation: 1 + wgov_global_explanation: 1 + wgov_local_explanation: 1 ibm_tg_gateway: connection: 3 data_transfer_global: 1000 @@ -1296,6 +1300,10 @@ resource_usage: wml_class1_ru: 20 # The number of resource units used for inferencing with class 1 type models where each ru is 1000 tokens wml_class2_ru: 20 # The number of resource units used for inferencing with class 2 type models where each ru is 1000 tokens wml_class3_ru: 20 # The number of resource units used for inferencing with class 3 type models where each ru is 1000 tokens + wgov_predictive_model_evaluation: 1 # The number of Predictive Model Evaluations + wgov_foundational_model_evaluation: 1 # The number of Foundational Model Evaluations + wgov_global_explanation: 1 # The number of Global Explanations + wgov_local_explanation: 1 # The number of Local Explanations (1 Ru ) ibm_tg_gateway.tg_gateway: connection: 25 # Monthly number of connections to the gateway From 28d5ff5bf7899f0dd8eb2675f4dda2713fb2cdca Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Thu, 18 Apr 2024 09:30:52 -0400 Subject: [PATCH 05/10] Add vars to UsageSchema --- internal/resources/ibm/resource_instance.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 2a333c592d4..b106c2aa657 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -104,6 +104,10 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "wml_class1_ru", DefaultValue: 0, ValueType: schema.Float64}, {Key: "wml_class2_ru", DefaultValue: 0, ValueType: schema.Float64}, {Key: "wml_class3_ru", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wgov_predictive_model_evaluation", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wgov_foundational_model_evaluation", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wgov_global_explanation", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wgov_local_explanation", DefaultValue: 0, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ @@ -117,7 +121,7 @@ var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]R "sysdig-monitor": GetSysdigCostComponenets, "continuous-delivery": GetContinuousDeliveryCostComponenets, "pm-20": GetWMLCostComponents, - "aiopenscale": GetWGOVCostComponents, + "aiopenscale": GetWGOVCostComponents, // watsonx.governance } func KMSKeyVersionsFreeCostComponent(r *ResourceInstance) *schema.CostComponent { From 7f53dee056d740f27b995c0102bdbf726fd1f16c Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Thu, 18 Apr 2024 09:31:45 -0400 Subject: [PATCH 06/10] Add base content for cost components --- .../ibm/resource_instance_ aiopenscale.go | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/internal/resources/ibm/resource_instance_ aiopenscale.go b/internal/resources/ibm/resource_instance_ aiopenscale.go index 00081686020..c8fd6e29c1e 100644 --- a/internal/resources/ibm/resource_instance_ aiopenscale.go +++ b/internal/resources/ibm/resource_instance_ aiopenscale.go @@ -1 +1,49 @@ package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +/** +* Lite: 'lite' (Free) +* Essentials: 'essentials' ($0.60 USD/RU) + */ +func GetWGOVCostComponents(r *ResourceInstance) []*schema.CostComponent { + if r.Plan == "essentials" { + // TODO + // Note: Global Catalog page only has one metric for "RESOURCE_UNITS"; it does not differentiate between types of models, evaluations, etc. May need to re-think the variables that have been used in the usage file. + } else 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 { + costComponent := schema.CostComponent{ + Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + return []*schema.CostComponent{ + &costComponent, + } + } +} + +/** +* 1 RU ($0.60 USD) for every: +* 1 WGOV_PredictiveModelEvals +* 1 WGOV_FoundationalModelEvals +* 1 WGOV_GlobalExplanations +* 500 WGOV_LocalExplanations + */ +func ResourceUnitCostComponent(r *ResourceInstance) *schema.CostComponent { + var quantity *decimal.Decimal + // TODO +} From 3f18a436206f9af5cfba33c01db0a98f7c8ad4e8 Mon Sep 17 00:00:00 2001 From: "hlem@ca.ibm.com" Date: Thu, 25 Apr 2024 15:26:44 -0400 Subject: [PATCH 07/10] finish wgov --- infracost-usage-example.yml | 56 ++++++-- .../resource_instance_test.golden | 79 +++++++++-- .../resource_instance_test.tf | 126 ++++++++++++++++++ .../resource_instance_test.usage.yml | 49 ++++++- internal/resources/ibm/resource_instance.go | 67 +++++++--- .../ibm/resource_instance_ aiopenscale.go | 49 ------- .../ibm/resource_instance_aiopenscale.go | 104 +++++++++++++++ 7 files changed, 438 insertions(+), 92 deletions(-) delete mode 100644 internal/resources/ibm/resource_instance_ aiopenscale.go create mode 100644 internal/resources/ibm/resource_instance_aiopenscale.go diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index 554fec01444..b0621205b9a 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -69,10 +69,18 @@ resource_type_default_usage: wml_class1_ru: 20 wml_class2_ru: 20 wml_class3_ru: 20 - wgov_predictive_model_evaluation: 1 - wgov_foundational_model_evaluation: 1 - wgov_global_explanation: 1 - wgov_local_explanation: 1 + wa_instance: 1 + wa_monthly_active_users: 1001 + wa_monthly_voice_users: 101 + wd_instance: 1 + wd_documents: 11000 + wd_queries: 11000 + wd_custom_models: 4 + wd_collections: 301 + scc_evaluations: 1 + data-science-experience_CAPACITY_UNIT_HOURS: 1 + aiopenscale_RESOURCE_UNITS: 1 + aiopenscale_MODELS_PER_MONTH: 1 ibm_tg_gateway: connection: 3 data_transfer_global: 1000 @@ -1295,15 +1303,45 @@ resource_usage: 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 + + ibm_resource_instance.watson_machine_learning_standard: 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 + wml_instance: 1 # The number of instances per month where each instance includes 2500 CUHs wml_class1_ru: 20 # The number of resource units used for inferencing with class 1 type models where each ru is 1000 tokens wml_class2_ru: 20 # The number of resource units used for inferencing with class 2 type models where each ru is 1000 tokens wml_class3_ru: 20 # The number of resource units used for inferencing with class 3 type models where each ru is 1000 tokens - wgov_predictive_model_evaluation: 1 # The number of Predictive Model Evaluations - wgov_foundational_model_evaluation: 1 # The number of Foundational Model Evaluations - wgov_global_explanation: 1 # The number of Global Explanations - wgov_local_explanation: 1 # The number of Local Explanations (1 Ru ) + + ibm_resource_instance.watson_assistant_plus: + wa_instance: 1 # The number of instances used per month where each instance includes 1000 monthly active users + wa_monthly_active_users: 1100 # The number of monthly active users + wa_monthly_voice_users: 100 # The number of monthly active voice users + + ibm_resource_instance.watson_discovery_plus: + wd_instance: 1 # Number of instances used per month + wd_documents: 11000 # Number of monthly documents created; 10,000 included in the Plus plan; $50 for every additional 1,000 documents. + wd_queries: 11000 # Number of queries documents created; 10,000 included in the Plus plan; $20 for every additional 1,000 queries. + + ibm_resource_instance.watson_discovery_enterprise: + wd_instance: 1 # Number of instances used per month + wd_documents: 101000 # Number of monthly documents created; 100,000 included in the Enterprise plan; $5 for every additional 1,000 documents. + wd_queries: 101000 # Number of queries documents created; 100,000 included in the Enterprise plan; $5 for every additional 1,000 queries. + 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 + + ibm_resource_instance.watson_governance_essentials: + aiopenscale_RESOURCE_UNITS: 1 + + ibm_resource_instance.watson_governance_standard_v2: + aiopenscale_MODELS_PER_MONTH: 1 ibm_tg_gateway.tg_gateway: connection: 25 # Monthly number of connections to the gateway diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden index 74402b58fbc..d554baa85ac 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden @@ -37,11 +37,20 @@ ├─ Key versions free allowance (first 5 Key Versions) 5 Key Versions $0.00 └─ Key versions 295 Key Versions $317.52 + ibm_resource_instance.resource_instance_logdna_14day + └─ Gigabyte Months (14-day) 1 Gigabyte Months $2.15 + + ibm_resource_instance.resource_instance_logdna_30day + └─ Gigabyte Months (30-day) 1 Gigabyte Months $3.23 + ibm_resource_instance.resource_instance_logdna_7day - └─ Gigabyte Months 10 Gigabyte Months $15.00 + └─ Gigabyte Months (7-day) 1 Gigabyte Months $1.50 ibm_resource_instance.resource_instance_logdna_7day_no_usage - └─ Gigabyte Months Monthly cost depends on usage: $1.50 per Gigabyte Months + └─ Gigabyte Months (7-day) Monthly cost depends on usage: $1.50 per Gigabyte Months + + ibm_resource_instance.resource_instance_logdna_hipaa30day + └─ Gigabyte Months (hipaa-30-day) 1 Gigabyte Months $4.12 ibm_resource_instance.resource_instance_logdna_lite └─ Lite plan 1 $0.00 @@ -51,18 +60,18 @@ ├─ Additional Time series (next 9000 Time series hour) 0 Time series hour $0.00 ├─ Additional Time series (next 90000 Time series hour) 0 Time series hour $0.00 ├─ Additional Time series (over 100000 Time series hour) 0 Time series hour $0.00 - ├─ Additional Containers 1,460 Container Hours $1.09 + ├─ Additional Container Hours 1,460 Container Hours $1.09 ├─ Additional API Calls 100,000 API Calls $1.08 - └─ Base Node Hour 730 Node Hours $37.72 + └─ Node Hours 730 Node Hours $37.72 ibm_resource_instance.resource_instance_monitoring_graduated_no_usage ├─ Additional Time series (first 1000 Time series hour) Monthly cost depends on usage: $0.0001195944 per Time series hour ├─ Additional Time series (next 9000 Time series hour) Monthly cost depends on usage: $0.0000747465 per Time series hour ├─ Additional Time series (next 90000 Time series hour) Monthly cost depends on usage: $0.0000448479 per Time series hour ├─ Additional Time series (over 100000 Time series hour) Monthly cost depends on usage: $0.0000298986 per Time series hour - ├─ Additional Containers Monthly cost depends on usage: $0.0007474653 per Container Hours + ├─ Additional Container Hours Monthly cost depends on usage: $0.0007474653 per Container Hours ├─ Additional API Calls Monthly cost depends on usage: $0.0000107635 per API Calls - └─ Base Node Hour Monthly cost depends on usage: $0.0516648 per Node Hours + └─ Node Hours Monthly cost depends on usage: $0.0516648 per Node Hours ibm_resource_instance.resource_instance_monitoring_lite └─ Lite plan 1 $0.00 @@ -74,6 +83,55 @@ ├─ 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 + └─ Monthly Active Users using voice 1 1K MAU $90.00 + + ibm_resource_instance.wa_instance_lite + └─ Lite plan 1 $0.00 + + ibm_resource_instance.wa_instance_plus + ├─ Instance (1000 MAU included) 1 Instance $140.00 + ├─ Additional Monthly Active Users 10 100 MAU $140.00 + └─ Monthly Active Users using voice 1 100 MAU $9.00 + + ibm_resource_instance.wa_instance_trial + └─ Trial 1 $0.00 + + ibm_resource_instance.watson_discovery_enterprise + ├─ Instance 1 Instance $5,000.00 + ├─ Additional Monthly Documents 1,000 Documents $5.00 + ├─ Additional Monthly Queries 1,000 Queries $5.00 + ├─ Additional Monthly Custom Models 1 Custom Models $500.00 + └─ Additional Monthly Collections 1 Hundred Collections $500.00 + + ibm_resource_instance.watson_discovery_plus + ├─ Instance 1 Instance $500.00 + ├─ Additional Monthly Documents 1,000 Documents $50.00 + └─ Additional Monthly Queries 1,000 Queries $20.00 + + ibm_resource_instance.watson_governance_essentials + └─ Resource Units 100 RU $60.00 + + ibm_resource_instance.watson_governance_lite + └─ Lite plan 1 $0.00 + + ibm_resource_instance.watson_governance_standard_v2 + └─ Deployed Models 1 Model $261.00 + + ibm_resource_instance.watson_studio_lite + └─ Lite plan 1 $0.00 + + ibm_resource_instance.watson_studio_professional + └─ Capacity Unit-Hours 1 CUH $1.02 + ibm_resource_instance.wml_instance_essentials ├─ Capacity Unit-Hours 20 CUH $10.40 ├─ Class 1 Resource Units 50 RU $0.03 @@ -84,12 +142,13 @@ └─ Lite plan 1 $0.00 ibm_resource_instance.wml_instance_standard - ├─ Capacity Unit-Hours 2,500 CUH $1,050.00 + ├─ Instance (2500 CUH included) 1 Instance $1,050.00 + ├─ Additional Capacity Unit-Hours Monthly cost depends on usage: $0.42 per CUH ├─ Class 1 Resource Units 50 RU $0.03 ├─ Class 2 Resource Units 50 RU $0.09 └─ Class 3 Resource Units 50 RU $0.25 - OVERALL TOTAL $2,381.14 + OVERALL TOTAL $15,791.56 ────────────────────────────────── -19 cloud resources were detected: -∙ 19 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file +35 cloud resources were detected: +∙ 35 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf index a2f1b94b515..b3945faa73d 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf @@ -63,6 +63,26 @@ resource "ibm_resource_instance" "resource_instance_logdna_7day_no_usage" { plan = "7-day" location = "us-south" } +resource "ibm_resource_instance" "resource_instance_logdna_14day" { + name = "logdna-14day" + service = "logdna" + plan = "14-day" + location = "us-south" +} + +resource "ibm_resource_instance" "resource_instance_logdna_30day" { + name = "logdna-30day" + service = "logdna" + plan = "30-day" + location = "us-south" +} + +resource "ibm_resource_instance" "resource_instance_logdna_hipaa30day" { + name = "logdna-hipaa30day" + service = "logdna" + plan = "hipaa-30-day" + location = "us-south" +} resource "ibm_resource_instance" "resource_instance_activity_tracker_lite" { name = "activity-tracker-lite" @@ -152,3 +172,109 @@ resource "ibm_resource_instance" "wml_instance_standard" { location = "us-south" resource_group_id = "default" } + +resource "ibm_resource_instance" "wa_instance_lite" { + name = "wa_lite" + service = "conversation" + plan = "lite" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "wa_instance_trial" { + name = "wa_trial" + service = "conversation" + plan = "plus-trial" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "wa_instance_plus" { + name = "wa_plus" + service = "conversation" + plan = "plus" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "wa_instance_enterprise" { + name = "wa_enterprise" + service = "conversation" + plan = "enterprise" + location = "us-south" + resource_group_id = "default" +} + +# Watson Discovery +resource "ibm_resource_instance" "watson_discovery_plus" { + name = "wd_plus" + service = "discovery" + plan = "plus" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "watson_discovery_enterprise" { + name = "wd_enterprise" + service = "discovery" + plan = "enterprise" + location = "us-south" + 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" + plan = "professional-v1" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "watson_studio_lite" { + name = "ws_lite" + service = "data-science-experience" + plan = "free-v1" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "watson_governance_lite" { + name = "wgov_lite" + service = "aiopenscale" + plan = "lite" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "watson_governance_essentials" { + name = "wgov_essentials" + service = "aiopenscale" + plan = "essentials" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "watson_governance_standard_v2" { + name = "wgov_standard_v2" + service = "aiopenscale" + plan = "standard-v2" + location = "us-south" + resource_group_id = "default" +} diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml index b1e72a9a79d..7cc519b8d6a 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml @@ -10,9 +10,15 @@ resource_usage: appid_users: 1000 appid_advanced_authentications: 20000 ibm_resource_instance.resource_instance_logdna_7day: - logdna_gigabyte_months: 10 + logdna_gigabyte_months: 1 ibm_resource_instance.resource_instance_logdna_lite: - logdna_gigabyte_months: 10 + logdna_gigabyte_months: 11 + ibm_resource_instance.resource_instance_logdna_14day: + logdna_gigabyte_months: 1 + ibm_resource_instance.resource_instance_logdna_30day: + logdna_gigabyte_months: 1 + ibm_resource_instance.resource_instance_logdna_hipaa30day: + logdna_gigabyte_months: 1 ibm_resource_instance.resource_instance_activity_tracker_7day: activitytracker_gigabyte_months: 10 ibm_resource_instance.resource_instance_activity_tracker_lite: @@ -48,4 +54,43 @@ resource_usage: wml_class1_ru: 50 wml_class2_ru: 50 wml_class3_ru: 50 + ibm_resource_instance.wa_instance_plus: + wa_instance: 1 + wa_monthly_active_users: 2000 + wa_monthly_voice_users: 100 + ibm_resource_instance.wa_instance_enterprise: + wa_instance: 1 + wa_monthly_active_users: 51000 + wa_monthly_voice_users: 1000 + ibm_resource_instance.watson_discovery_plus: + wd_instance: 1 # Number of instances used per month + wd_documents: 11000 # Number of monthly documents created; 10,000 included in the Plus plan; $50 for every additional 1,000 documents. + wd_queries: 11000 # Number of queries documents created; 10,000 included in the Plus plan; $20 for every additional 1,000 queries. + + ibm_resource_instance.watson_discovery_enterprise: + wd_instance: 1 # Number of instances used per month + wd_documents: 101000 # Number of monthly documents created; 100,000 included in the Enterprise plan; $5 for every additional 1,000 documents. + wd_queries: 101000 # Number of queries documents created; 100,000 included in the Enterprise plan; $5 for every additional 1,000 queries. + 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 + + ibm_resource_instance.watson_studio_lite: + data-science-experience_CAPACITY_UNIT_HOURS: 10 + + ibm_resource_instance.watson_governance_essentials: + aiopenscale_RESOURCE_UNITS: 100 + + ibm_resource_instance.watson_governance_standard_v2: + aiopenscale_MODELS_PER_MONTH:: 2 + + diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index b106c2aa657..480ad33a1a1 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -64,12 +64,23 @@ type ResourceInstance struct { WML_Class1RU *float64 `infracost_usage:"wml_class1_ru"` WML_Class2RU *float64 `infracost_usage:"wml_class2_ru"` WML_Class3RU *float64 `infracost_usage:"wml_class3_ru"` - // watsonx.gov - // https://dataplatform.cloud.ibm.com/docs/content/svc-welcome/aiopenscale.html?context=cpdaas&audience=wdp - WGOV_PredictiveModelEvals *float64 `infracost_usage:"wgov_predictive_model_evaluation"` - WGOV_FoundationalModelEvals *float64 `infracost_usage:"wgov_foundational_model_evaluation"` - WGOV_GlobalExplanations *float64 `infracost_usage:"wgov_global_explanation"` - WGOV_LocalExplanations *float64 `infracost_usage:"wgov_local_explanation"` + // Watson Assistant + WA_Instance *float64 `infracost_usage:"wa_instance"` + WA_mau *float64 `infracost_usage:"wa_monthly_active_users"` + WA_vu *float64 `infracost_usage:"wa_monthly_voice_users"` + // Watson Discovery + WD_Instance *float64 `infracost_usage:"wd_instance"` + WD_Documents *float64 `infracost_usage:"wd_documents"` + 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"` + // Watson.governance + WGOV_ru *float64 `infracost_usage:"aiopenscale_RESOURCE_UNITS"` + WGOV_Models *float64 `infracost_usage:"aiopenscale_MODELS_PER_MONTH"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -104,24 +115,36 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "wml_class1_ru", DefaultValue: 0, ValueType: schema.Float64}, {Key: "wml_class2_ru", DefaultValue: 0, ValueType: schema.Float64}, {Key: "wml_class3_ru", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "wgov_predictive_model_evaluation", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "wgov_foundational_model_evaluation", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "wgov_global_explanation", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "wgov_local_explanation", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wa_instance", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wa_monthly_active_users", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wa_monthly_voice_users", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wd_instance", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "wd_documents", DefaultValue: 0, ValueType: schema.Float64}, + {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}, + {Key: "aiopenscale_RESOURCE_UNITS", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "aiopenscale_MODELS_PER_MONTH", DefaultValue: 1, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ - "kms": GetKMSCostComponents, - "secrets-manager": GetSecretsManagerCostComponents, - "appid": GetAppIDCostComponents, - "appconnect": GetAppConnectCostComponents, - "power-iaas": GetPowerCostComponents, - "logdna": GetLogDNACostComponents, - "logdnaat": GetActivityTrackerCostComponents, - "sysdig-monitor": GetSysdigCostComponenets, - "continuous-delivery": GetContinuousDeliveryCostComponenets, - "pm-20": GetWMLCostComponents, - "aiopenscale": GetWGOVCostComponents, // watsonx.governance + "kms": GetKMSCostComponents, + "secrets-manager": GetSecretsManagerCostComponents, + "appid": GetAppIDCostComponents, + "appconnect": GetAppConnectCostComponents, + "power-iaas": GetPowerCostComponents, + "logdna": GetLogDNACostComponents, + "logdnaat": GetActivityTrackerCostComponents, + "sysdig-monitor": GetSysdigCostComponenets, + "continuous-delivery": GetContinuousDeliveryCostComponenets, + "pm-20": GetWMLCostComponents, + "conversation": GetWACostComponents, + "discovery": GetWDCostComponents, + "compliance": GetSCCCostComponents, + "data-science-experience": GetWSCostComponents, + "aiopenscale": GetWGOVCostComponents, } func KMSKeyVersionsFreeCostComponent(r *ResourceInstance) *schema.CostComponent { @@ -484,7 +507,7 @@ func GetLogDNACostComponents(r *ResourceInstance) []*schema.CostComponent { } } else { return []*schema.CostComponent{{ - Name: "Gigabyte Months", + Name: fmt.Sprintf("Gigabyte Months (%s)", r.Plan), Unit: "Gigabyte Months", UnitMultiplier: decimal.NewFromInt(1), MonthlyQuantity: q, diff --git a/internal/resources/ibm/resource_instance_ aiopenscale.go b/internal/resources/ibm/resource_instance_ aiopenscale.go deleted file mode 100644 index c8fd6e29c1e..00000000000 --- a/internal/resources/ibm/resource_instance_ aiopenscale.go +++ /dev/null @@ -1,49 +0,0 @@ -package ibm - -import ( - "fmt" - - "github.com/infracost/infracost/internal/schema" - "github.com/shopspring/decimal" -) - -/** -* Lite: 'lite' (Free) -* Essentials: 'essentials' ($0.60 USD/RU) - */ -func GetWGOVCostComponents(r *ResourceInstance) []*schema.CostComponent { - if r.Plan == "essentials" { - // TODO - // Note: Global Catalog page only has one metric for "RESOURCE_UNITS"; it does not differentiate between types of models, evaluations, etc. May need to re-think the variables that have been used in the usage file. - } else 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 { - costComponent := schema.CostComponent{ - Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan), - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), - } - costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) - return []*schema.CostComponent{ - &costComponent, - } - } -} - -/** -* 1 RU ($0.60 USD) for every: -* 1 WGOV_PredictiveModelEvals -* 1 WGOV_FoundationalModelEvals -* 1 WGOV_GlobalExplanations -* 500 WGOV_LocalExplanations - */ -func ResourceUnitCostComponent(r *ResourceInstance) *schema.CostComponent { - var quantity *decimal.Decimal - // TODO -} diff --git a/internal/resources/ibm/resource_instance_aiopenscale.go b/internal/resources/ibm/resource_instance_aiopenscale.go new file mode 100644 index 00000000000..be051b05e34 --- /dev/null +++ b/internal/resources/ibm/resource_instance_aiopenscale.go @@ -0,0 +1,104 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +/** + * Lite: 'lite' (Free) + * Essentials: 'essentials' + * Standard V2 == 'standard-v2' + */ +func GetWGOVCostComponents(r *ResourceInstance) []*schema.CostComponent { + if r.Plan == "essentials" { + return []*schema.CostComponent{ + WGOVResourceUnitsCostComponent(r), + } + } else if r.Plan == "standard-v2" { + return []*schema.CostComponent{ + WGOVModelCostComponent(r), + } + } else 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 { + costComponent := schema.CostComponent{ + Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + return []*schema.CostComponent{ + &costComponent, + } + } +} + +/** + * 1 RU for every: + * 1 WGOV_PredictiveModelEvals + * 1 WGOV_FoundationalModelEvals + * 1 WGOV_GlobalExplanations + * 500 WGOV_LocalExplanations + * basically, everything converts into an RU for charging costs, with limits + */ +func WGOVResourceUnitsCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.WGOV_ru != nil { + q = decimalPtr(decimal.NewFromFloat(*r.WGOV_ru)) + } + return &schema.CostComponent{ + Name: "Resource Units", + Unit: "RU", + 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("RESOURCE_UNITS"), + }, + } +} + +/** + * No restrictions with unlimited evaluations performed on a model, charged on a per model basis instead + */ +func WGOVModelCostComponent(r *ResourceInstance) *schema.CostComponent { + var q *decimal.Decimal + if r.WGOV_Models != nil { + q = decimalPtr(decimal.NewFromFloat(*r.WGOV_Models)) + } else { + q = decimalPtr(decimal.NewFromInt(1)) + } + return &schema.CostComponent{ + Name: "Deployed Models", + Unit: "Model", + 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("MODELS_PER_MONTH"), + }, + } +} From 8f4602bc09cd1756b924ba36d1dab05ec617f398 Mon Sep 17 00:00:00 2001 From: "hlem@ca.ibm.com" Date: Thu, 25 Apr 2024 15:37:30 -0400 Subject: [PATCH 08/10] fix merge --- .../resource_instance_test/resource_instance_test.golden | 6 ------ 1 file changed, 6 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden index b088c97b1fb..d554baa85ac 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden @@ -43,12 +43,6 @@ ibm_resource_instance.resource_instance_logdna_30day └─ Gigabyte Months (30-day) 1 Gigabyte Months $3.23 - ibm_resource_instance.resource_instance_logdna_14day - └─ Gigabyte Months (14-day) 1 Gigabyte Months $2.15 - - ibm_resource_instance.resource_instance_logdna_30day - └─ Gigabyte Months (30-day) 1 Gigabyte Months $3.23 - ibm_resource_instance.resource_instance_logdna_7day └─ Gigabyte Months (7-day) 1 Gigabyte Months $1.50 From 2435b50d4df69654beeedf00e328c4c8a74de898 Mon Sep 17 00:00:00 2001 From: "hlem@ca.ibm.com" Date: Thu, 25 Apr 2024 15:48:00 -0400 Subject: [PATCH 09/10] remove duplicates in test --- .../resource_instance_test.tf | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf index f01655ea088..b3945faa73d 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf @@ -77,26 +77,6 @@ resource "ibm_resource_instance" "resource_instance_logdna_30day" { location = "us-south" } -resource "ibm_resource_instance" "resource_instance_logdna_hipaa30day" { - name = "logdna-hipaa30day" - service = "logdna" - plan = "hipaa-30-day" - location = "us-south" -} -resource "ibm_resource_instance" "resource_instance_logdna_14day" { - name = "logdna-14day" - service = "logdna" - plan = "14-day" - location = "us-south" -} - -resource "ibm_resource_instance" "resource_instance_logdna_30day" { - name = "logdna-30day" - service = "logdna" - plan = "30-day" - location = "us-south" -} - resource "ibm_resource_instance" "resource_instance_logdna_hipaa30day" { name = "logdna-hipaa30day" service = "logdna" From 36c4abd9e2937a16f95c7681099ff078cff88673 Mon Sep 17 00:00:00 2001 From: "hlem@ca.ibm.com" Date: Thu, 25 Apr 2024 15:50:18 -0400 Subject: [PATCH 10/10] add missing catalog ids for observability resources --- internal/providers/terraform/ibm/ibm.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/providers/terraform/ibm/ibm.go b/internal/providers/terraform/ibm/ibm.go index 2ccd7d744e8..26d8b953e25 100644 --- a/internal/providers/terraform/ibm/ibm.go +++ b/internal/providers/terraform/ibm/ibm.go @@ -74,6 +74,9 @@ var globalCatalogServiceId = map[string]catalogMetadata{ "wx": {"51c53b72-918f-4869-b834-2d99eb28422a", []string{}, nil}, "conversation": {"7045626d-55e3-4418-be11-683a26dbc1e5", []string{}, nil}, "aiopenscale": {"2ad019f3-0fd6-4c25-966d-f3952481a870", []string{}, nil}, + "sysdig-monitor": {"090c2c10-8c38-11e8-bec2-493df9c49eb8", []string{}, nil}, + "sysdig-secure": {"e831e900-82d6-11ec-95c5-c12c5a5d9687", []string{}, nil}, + "logdna": {"e13e1860-959c-11e8-871e-ad157af61ad7", []string{}, nil}, } func SetCatalogMetadata(d *schema.ResourceData, resourceType string, config map[string]any) {