Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ibm_is_instance pricing and relevant tests #199

Merged
merged 5 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/providers/terraform/ibm/is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ func newIsInstance(d *schema.ResourceData, u *schema.UsageData) *schema.Resource
isDedicated := !((dedicatedHost == "") && (dedicatedHostGroup == ""))
name := d.Get("name").String()

boot_volume := make([]struct {
bootVolume := make([]struct {
Name string
Size int64
}, 0)

boot_volume_parse := d.Get("boot_volume").Array()
if len(boot_volume_parse) > 0 {
for _, volume := range boot_volume_parse {
bootVolumeParse := d.Get("boot_volume").Array()
if len(bootVolumeParse) > 0 {
luisarojas marked this conversation as resolved.
Show resolved Hide resolved
for _, volume := range bootVolumeParse {
name := volume.Get("name").String()
if name == "" {
name = "Unnamed boot volume"
Expand All @@ -41,7 +41,7 @@ func newIsInstance(d *schema.ResourceData, u *schema.UsageData) *schema.Resource
if size == 0 {
size = 100
}
boot_volume = append(boot_volume, struct {
bootVolume = append(bootVolume, struct {
Name string
Size int64
}{Name: name, Size: size})
Expand All @@ -54,7 +54,7 @@ func newIsInstance(d *schema.ResourceData, u *schema.UsageData) *schema.Resource
Profile: profile,
Zone: zone,
IsDedicated: isDedicated,
BootVolume: boot_volume,
BootVolume: bootVolume,
}

r.PopulateUsage(u)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,21 @@

Name Monthly Qty Unit Monthly Cost

ibm_is_instance.testBalancedInstance
├─ CPU hours (32 CPUs, us-east-1) (first 1 CPU hours) 1 CPU hours $0.31
├─ CPU hours (32 CPUs, us-east-1) (over 0 CPU hours) 1 CPU hours $0.02
├─ Memory hours (128 GB, us-east-1) (first 1 Memory hours) 1 Memory hours $0.57
├─ Memory hours (128 GB, us-east-1) (over 0 Memory hours) 1 Memory hours $0.01
└─ Storage GB hours (600 GB * 2, us-east-1) 876,000 Storage GB hours $23,652.00

ibm_is_instance.testBalancedInstanceWithBootVolume
├─ CPU hours (8 CPUs, us-east-1) (first 1 CPU hours) 1 CPU hours $0.31
├─ CPU hours (8 CPUs, us-east-1) (over 0 CPU hours) 1 CPU hours $0.02
├─ Memory hours (32 GB, us-east-1) (first 1 Memory hours) 1 Memory hours $0.57
├─ Memory hours (32 GB, us-east-1) (over 0 Memory hours) 1 Memory hours $0.01
└─ Boot volume (boot-volume-label, 150 GB) 109,500 GB Hours $12.59

ibm_is_instance.testComputeInstance
├─ CPU hours (2 CPUs, us-east-1) (first 1 CPU hours) 1 CPU hours $0.31
├─ CPU hours (2 CPUs, us-east-1) (over 0 CPU hours) 1 CPU hours $0.02
└─ Memory hours (4 GB, us-east-1) (first 1 Memory hours) 1 Memory hours $0.84
└─ Memory hours (4 GB, us-east-1) (over 0 Memory hours) 1 Memory hours $0.01

ibm_is_instance.testGpuInstance
├─ CPU hours (16 CPUs, us-east-1) (first 1 CPU hours) 1 CPU hours $0.33
├─ CPU hours (16 CPUs, us-east-1) (over 0 CPU hours) 1 CPU hours $0.03
├─ Memory hours (128 GB, us-east-1) (first 1 Memory hours) 1 Memory hours $0.45
├─ Memory hours (128 GB, us-east-1) (over 0 Memory hours) 1 Memory hours $0.00
└─ Gpu hours (2 GPUs, Tesla V100, us-east-1) 1,460 Gpu hours $3,051.40

ibm_is_instance.testIbmZInstance
├─ CPU hours (16 CPUs, us-east-1) (first 1 CPU hours) 1 CPU hours $0.39
├─ CPU hours (16 CPUs, us-east-1) (over 0 CPU hours) 1 CPU hours $0.05
└─ Memory hours (64 GB, us-east-1) (first 1 Memory hours) 1 Memory hours $0.56
└─ Memory hours (64 GB, us-east-1) (over 0 Memory hours) 1 Memory hours $0.01

ibm_is_instance.testInstanceWithoutUsage
├─ CPU hours (2 CPUs, us-east-1) (first 1 CPU hours) Monthly cost depends on usage: $0.31 per CPU hours
├─ CPU hours (2 CPUs, us-east-1) (over 0 CPU hours) Monthly cost depends on usage: $0.0249876337 per CPU hours
└─ Memory hours (4 GB, us-east-1) (first 1 Memory hours) Monthly cost depends on usage: $0.84 per Memory hours
└─ Memory hours (4 GB, us-east-1) (over 0 Memory hours) Monthly cost depends on usage: $0.0075416569 per Memory hours

ibm_is_vpc.testVpc
├─ VPC instance 1 Instance $0.00
├─ VPC egress free allowance (first 5GB) Monthly cost depends on usage: $0.00 per GB
└─ VPC egress us-east (first 9995 GB) Monthly cost depends on usage: $0.090915 per GB
└─ VPC egress us-east (next 40000 GB) Monthly cost depends on usage: $0.086735 per GB
└─ VPC egress us-east (next 100000 GB) Monthly cost depends on usage: $0.07315 per GB
└─ VPC egress us-east (over 149995 GB) Monthly cost depends on usage: $0.05225 per GB

OVERALL TOTAL $26,720.80
Name Monthly Qty Unit Monthly Cost

ibm_is_instance.vsi
luisarojas marked this conversation as resolved.
Show resolved Hide resolved
└─ Instance Hours (cx3d-2x5) 730 Hours $73.00

ibm_is_vpc.vpc
├─ VPC instance 1 Instance $0.00
├─ VPC egress free allowance (first 5GB) Monthly cost depends on usage: $0.00 per GB
└─ VPC egress us-south (first 9995 GB) Monthly cost depends on usage: $0.090915 per GB
└─ VPC egress us-south (next 40000 GB) Monthly cost depends on usage: $0.086735 per GB
└─ VPC egress us-south (next 100000 GB) Monthly cost depends on usage: $0.07315 per GB
└─ VPC egress us-south (over 149995 GB) Monthly cost depends on usage: $0.05225 per GB

OVERALL TOTAL $73.00
──────────────────────────────────
9 cloud resources were detected:
7 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
4 cloud resources were detected:
2 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
∙ 2 were free:
∙ 1 x ibm_is_ssh_key
∙ 1 x ibm_is_subnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,141 +8,37 @@ terraform {
}

provider "ibm" {
region = "us-east"
region = "us-south"
}

resource "ibm_is_vpc" "testVpc" {
resource "ibm_is_vpc" "vpc" {
name = "test-vpc"
}

resource "ibm_is_subnet" "testSubnet" {
resource "ibm_is_subnet" "subnet" {
name = "test-subnet"
vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
vpc = ibm_is_vpc.vpc.id
zone = "us-south-1"
ipv4_cidr_block = "10.240.0.0/24"
}

resource "ibm_is_ssh_key" "testSshKey" {
resource "ibm_is_ssh_key" "ssh_key" {
name = "test-ssh"
public_key = file("~/.ssh/id_rsa.pub")
}

resource "ibm_is_instance" "testBalancedInstance" {
name = "test-instance-1"
resource "ibm_is_instance" "vsi" {
name = "vsi-instance"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "bx2d-32x128"

primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]
}

resource "ibm_is_instance" "testComputeInstance" {
name = "test-instance-2"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "cx2-2x4"

profile = "cx3d-2x5"
keys = [ibm_is_ssh_key.ssh_key.id]
vpc = ibm_is_vpc.vpc.id
zone = "us-south-1"
primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
subnet = ibm_is_subnet.subnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]
}

resource "ibm_is_instance" "testGpuInstance" {
luisarojas marked this conversation as resolved.
Show resolved Hide resolved
name = "test-instance-3"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "gx2-16x128x2v100"

primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]
}

resource "ibm_is_instance" "testIbmZInstance" {
name = "test-instance-4"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "bz2-16x64"

primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]
}

resource "ibm_is_instance" "testInstanceWithoutUsage" {
name = "test-instance-5"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "cx2-2x4"

primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]
}


resource "ibm_is_instance" "testBalancedInstanceWithBootVolume" {
name = "test-instance-6"
image = "r006-f137ea64-0d27-4d81-afe0-353fd0557e81"
profile = "bx2-8x32"

primary_network_interface {
subnet = ibm_is_subnet.testSubnet.id
}

network_interfaces {
name = "eth1"
subnet = ibm_is_subnet.testSubnet.id
}

vpc = ibm_is_vpc.testVpc.id
zone = "us-east-1"
keys = [ibm_is_ssh_key.testSshKey.id]

boot_volume {
name = "boot-volume-label"
size = 150
subnet = ibm_is_subnet.subnet.id
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
version: 0.1
resource_usage:
ibm_is_instance.testBalancedInstance:
ibm_is_instance.vsi:
monthly_instance_hours: 730
ibm_is_instance.testComputeInstance:
monthly_instance_hours: 730
ibm_is_instance.testGpuInstance:
monthly_instance_hours: 730
ibm_is_instance.testIbmZInstance:
monthly_instance_hours: 730
ibm_is_instance.testBalancedInstanceWithBootVolume:
monthly_instance_hours: 730
Loading
Loading