From 665f43187c3d5690fa51e42712143e2c7beb67df Mon Sep 17 00:00:00 2001 From: Hilton Lem <101275725+hiltol@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:00:35 -0400 Subject: [PATCH] add missing tiers to pi volumes (#193) --- .../ibm_pi_volume_test.golden | 61 ++++++++++++------- .../ibm_pi_volume_test/ibm_pi_volume_test.tf | 38 +++++++++--- internal/resources/ibm/ibm_pi_volume.go | 4 +- 3 files changed, 72 insertions(+), 31 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.golden b/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.golden index 5925e7fccd9..b85c7e451ca 100644 --- a/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.golden +++ b/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.golden @@ -1,27 +1,42 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_pi_volume.pi_volume_affinity_set - └─ Volume (100 GB, example-volume) Price dependent on affinity settings 73,000 Gigabyte Instance Hours $0.00 - - ibm_pi_volume.pi_volume_tier1 - └─ Volume (100 GB, tier1, example-volume) 73,000 Gigabyte Instance Hours $20.00 - - ibm_pi_volume.pi_volume_tier1_no_usage - └─ Volume (100 GB, tier1, example-volume) Monthly cost depends on usage: $0.000274 per Gigabyte Instance Hours - - ibm_pi_volume.pi_volume_tier3 - └─ Volume (100 GB, tier3, example-volume) 73,000 Gigabyte Instance Hours $10.45 - - ibm_pi_volume.pi_volume_volume_set - └─ Volume pool (100 GB, example-volume) Price dependent on volume pool settings 73,000 Gigabyte Instance Hours $0.00 - - ibm_resource_instance.powervs_service - └─ Power instance 1 Instance $0.00 - - OVERALL TOTAL $30.45 + Name Monthly Qty Unit Monthly Cost + + ibm_pi_volume.pi_volume_affinity_set + └─ Volume (100 GB, affinity-volume-set) Price dependent on affinity settings 73,000 Gigabyte Instance Hours $0.00 + + ibm_pi_volume.pi_volume_tier0 + └─ Volume (100 GB, tier0, tier0-volume) 73,000 Gigabyte Instance Hours $0.00 + + ibm_pi_volume.pi_volume_tier0_no_usage + └─ Volume (100 GB, tier0, tier0-volume2) Monthly cost depends on usage: $0.00 per Gigabyte Instance Hours + + ibm_pi_volume.pi_volume_tier1 + └─ Volume (100 GB, tier1, tier1-volume) 73,000 Gigabyte Instance Hours $20.00 + + ibm_pi_volume.pi_volume_tier1_no_usage + └─ Volume (100 GB, tier1, tier1-volume2) Monthly cost depends on usage: $0.000274 per Gigabyte Instance Hours + + ibm_pi_volume.pi_volume_tier3 + └─ Volume (100 GB, tier3, tier3-volume) 73,000 Gigabyte Instance Hours $10.45 + + ibm_pi_volume.pi_volume_tier3_no_usage + └─ Volume (100 GB, tier3, tier3-volume2) Monthly cost depends on usage: $0.000143165 per Gigabyte Instance Hours + + ibm_pi_volume.pi_volume_tier5k + └─ Volume (100 GB, tier5k, tier5k-volume) 73,000 Gigabyte Instance Hours $0.00 + + ibm_pi_volume.pi_volume_tier5k_no_usage + └─ Volume (100 GB, tier5k, tier5k-volume2) Monthly cost depends on usage: $0.00 per Gigabyte Instance Hours + + ibm_pi_volume.pi_volume_volume_set + └─ Volume pool (100 GB, volume-pool) Price dependent on volume pool settings 73,000 Gigabyte Instance Hours $0.00 + + ibm_resource_instance.powervs_service + └─ Power instance 1 Instance $0.00 + + OVERALL TOTAL $30.45 ────────────────────────────────── -9 cloud resources were detected: -∙ 8 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file +12 cloud resources were detected: +∙ 11 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file ∙ 1 was free: ∙ 1 x ibm_resource_group \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.tf b/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.tf index 6bd1a525dc2..038dd9453d4 100644 --- a/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.tf +++ b/internal/providers/terraform/ibm/testdata/ibm_pi_volume_test/ibm_pi_volume_test.tf @@ -23,7 +23,7 @@ resource "ibm_resource_instance" "powervs_service" { } resource "ibm_pi_volume" "pi_volume_affinity_set" { - pi_volume_name = "example-volume" + pi_volume_name = "affinity-volume-set" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_affinity_policy = "affinity" @@ -31,7 +31,7 @@ resource "ibm_pi_volume" "pi_volume_affinity_set" { } resource "ibm_pi_volume" "pi_volume_volume_set" { - pi_volume_name = "example-volume" + pi_volume_name = "volume-pool" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_pool = "volume-pool-name" @@ -39,7 +39,7 @@ resource "ibm_pi_volume" "pi_volume_volume_set" { } resource "ibm_pi_volume" "pi_volume_tier0" { - pi_volume_name = "example-volume" + pi_volume_name = "tier0-volume" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_type = "tier0" @@ -47,7 +47,7 @@ resource "ibm_pi_volume" "pi_volume_tier0" { } resource "ibm_pi_volume" "pi_volume_tier1" { - pi_volume_name = "example-volume" + pi_volume_name = "tier1-volume" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_type = "tier1" @@ -55,7 +55,7 @@ resource "ibm_pi_volume" "pi_volume_tier1" { } resource "ibm_pi_volume" "pi_volume_tier3" { - pi_volume_name = "example-volume" + pi_volume_name = "tier3-volume" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_type = "tier3" @@ -63,17 +63,41 @@ resource "ibm_pi_volume" "pi_volume_tier3" { } resource "ibm_pi_volume" "pi_volume_tier5k" { - pi_volume_name = "example-volume" + pi_volume_name = "tier5k-volume" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_type = "tier5k" pi_volume_shareable = false } +resource "ibm_pi_volume" "pi_volume_tier0_no_usage" { + pi_volume_name = "tier0-volume2" + pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid + pi_volume_size = 100 + pi_volume_type = "tier0" + pi_volume_shareable = false +} + resource "ibm_pi_volume" "pi_volume_tier1_no_usage" { - pi_volume_name = "example-volume" + pi_volume_name = "tier1-volume2" pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid pi_volume_size = 100 pi_volume_type = "tier1" pi_volume_shareable = false } + +resource "ibm_pi_volume" "pi_volume_tier3_no_usage" { + pi_volume_name = "tier3-volume2" + pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid + pi_volume_size = 100 + pi_volume_type = "tier3" + pi_volume_shareable = false +} + +resource "ibm_pi_volume" "pi_volume_tier5k_no_usage" { + pi_volume_name = "tier5k-volume2" + pi_cloud_instance_id = ibm_resource_instance.powervs_service.guid + pi_volume_size = 100 + pi_volume_type = "tier5k" + pi_volume_shareable = false +} diff --git a/internal/resources/ibm/ibm_pi_volume.go b/internal/resources/ibm/ibm_pi_volume.go index 4cfb1090391..f7c9ca16132 100644 --- a/internal/resources/ibm/ibm_pi_volume.go +++ b/internal/resources/ibm/ibm_pi_volume.go @@ -38,9 +38,11 @@ var IbmPiVolumeUsageSchema = []*schema.UsageItem{ } var tierMapping = map[string]string{ + "tier0": "TIER_ZERO_STORAGE_GIGABYTE_HOURS", "tier1": "TIER_ONE_STORAGE_GIGABYTE_HOURS", "ssd": "TIER_ONE_STORAGE_GIGABYTE_HOURS", "tier3": "TIER_THREE_STORAGE_GIGABYTE_HOURS", + "tier5k": "FIXED_5K_OPS_GIGABYTE_HOURS", "standard": "TIER_THREE_STORAGE_GIGABYTE_HOURS", } @@ -103,7 +105,7 @@ func (r *IbmPiVolume) BuildResource() *schema.Resource { } costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0.0))) costComponents = append(costComponents, costComponent) - } else if r.Type == "tier1" || r.Type == "tier3" || r.Type == "standard" || r.Type == "ssd" { + } else if r.Type == "tier1" || r.Type == "tier3" || r.Type == "standard" || r.Type == "ssd" || r.Type == "tier0" || r.Type == "tier5k" { costComponent := &schema.CostComponent{ Name: fmt.Sprintf("Volume (%d GB, %s, %s)", r.Size, r.Type, r.Name),