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

Azure Machine Learning Compute Instance and Cluster #2902

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions infracost-usage-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,13 @@ resource_usage:
azurerm_lb.my_lb:
monthly_data_processed_gb: 100 # Monthly inbound and outbound data processed in GB.

azurerm_machine_learning_compute_cluster.my_cluster:
instances: 10 # Number of instances in the cluster.
monthly_hrs: 730 # Monthly number of hours each instance runs for.

azurerm_machine_learning_compute_instance.my_instances:
monthly_hrs: 730 # Monthly number of hours the instance runs for.

azurerm_managed_disk.my_disk:
monthly_disk_operations: 2000000 # Number of disk operations (writes, reads, deletes) using a unit size of 256KiB.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package azure

import (
"github.com/infracost/infracost/internal/resources/azure"
"github.com/infracost/infracost/internal/schema"
)

func getMachineLearningComputeClusterRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "azurerm_machine_learning_compute_cluster",
CoreRFunc: newMachineLearningComputeCluster,
ReferenceAttributes: []string{
"resource_group_name",
},
}
}

func newMachineLearningComputeCluster(d *schema.ResourceData) schema.CoreResource {
region := lookupRegion(d, []string{"resource_group_name"})
return &azure.MachineLearningComputeCluster{
Address: d.Address,
Region: region,
InstanceType: d.Get("vm_size").String(),
MinNodeCount: d.Get("scale_settings.0.min_node_count").Int(),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package azure_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestMachineLearningComputeCluster(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "machine_learning_compute_cluster_test")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package azure

import (
"github.com/infracost/infracost/internal/resources/azure"
"github.com/infracost/infracost/internal/schema"
)

func getMachineLearningComputeInstanceRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "azurerm_machine_learning_compute_instance",
CoreRFunc: newMachineLearningComputeInstance,
ReferenceAttributes: []string{
"resource_group_name",
},
}
}

func newMachineLearningComputeInstance(d *schema.ResourceData) schema.CoreResource {
region := lookupRegion(d, []string{"resource_group_name"})
return &azure.MachineLearningComputeInstance{
Address: d.Address,
Region: region,
InstanceType: d.Get("virtual_machine_size").String(),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package azure_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestMachineLearningComputeInstance(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "machine_learning_compute_instance_test")
}
5 changes: 5 additions & 0 deletions internal/providers/terraform/azure/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{
getPrivateDnsResolverInboundEndpointRegistryItem(),
getPrivateDnsResolverOutboundEndpointRegistryItem(),
getPrivateDnsResolverDnsForwardingRulesetRegistryItem(),
getMachineLearningComputeInstanceRegistryItem(),
getMachineLearningComputeClusterRegistryItem(),
}

// FreeResources grouped alphabetically
Expand Down Expand Up @@ -420,6 +422,9 @@ var FreeResources = []string{
"azurerm_logic_app_trigger_recurrence",
"azurerm_logic_app_workflow",

// Azure Machine Learning
"azurerm_machine_learning_workspace",

// Azure Management
"azurerm_management_group",
"azurerm_management_group_subscription_association",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
provider "azurerm" {
skip_provider_registration = true
features {}
}

resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}

locals {
vm_sizes = [
"Standard_D2s_v3",
"Standard_D4s_v3",
"Standard_D8s_v3",
"Standard_D16s_v3",
"Standard_DS12_v2",
"Standard_F4s_v2",
"Standard_F8s_v2",
"Standard_F16s_v2",
"Standard_E4s_v3",
"Standard_E8s_v3",
"Standard_E16s_v3",
"Standard_NC6",
"Standard_NC12",
"Standard_NC24",
"Standard_NV6",
"Standard_NV12",
"Standard_NV24",
]

min_node_counts = [0, 1, 4, 8, 16]

permutations = distinct(flatten([
for vm_size in local.vm_sizes : [
for min_node_count in local.min_node_counts : {
vm_size = vm_size
min_node_count = min_node_count
}
]
]))
}

resource "azurerm_storage_account" "example" {
name = "examplestorageaccount"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
account_tier = "Standard"
account_replication_type = "GRS"
}

resource "azurerm_machine_learning_workspace" "example" {
name = "example-workspace"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
key_vault_id = "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.KeyVault/vaults/example"
application_insights_id = "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Insights/components/example"

identity {
type = "SystemAssigned"
}

storage_account_id = azurerm_storage_account.example.id
}

resource "azurerm_machine_learning_compute_cluster" "example" {
for_each = { for entry in local.permutations : "${entry.vm_size}.${entry.min_node_count}" => entry }

name = "example-cluster"
location = azurerm_resource_group.example.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
vm_size = each.value.vm_size

scale_settings {
min_node_count = each.value.min_node_count
max_node_count = each.value.min_node_count + 1
scale_down_nodes_after_idle_duration = 30
}

vm_priority = "LowPriority"
}

resource "azurerm_machine_learning_compute_cluster" "with_monthly_hrs" {
name = "with-monthly-hrs"
location = azurerm_resource_group.example.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
vm_size = "Standard_D2s_v3"

scale_settings {
min_node_count = 2
max_node_count = 20
scale_down_nodes_after_idle_duration = 30
}

vm_priority = "LowPriority"
}

resource "azurerm_machine_learning_compute_cluster" "with_monthly_hrs_zero_min_node_count" {
name = "with-monthly-hrs"
location = azurerm_resource_group.example.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
vm_size = "Standard_D2s_v3"

scale_settings {
min_node_count = 0
max_node_count = 20
scale_down_nodes_after_idle_duration = 30
}

vm_priority = "LowPriority"
}

resource "azurerm_machine_learning_compute_cluster" "with_instances" {
name = "with-monthly-hrs"
location = azurerm_resource_group.example.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
vm_size = "Standard_D2s_v3"

scale_settings {
min_node_count = 2
max_node_count = 20
scale_down_nodes_after_idle_duration = 30
}

vm_priority = "LowPriority"
}

resource "azurerm_machine_learning_compute_cluster" "with_instances_and_monthly_hrs" {
name = "with-monthly-hrs"
location = azurerm_resource_group.example.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
vm_size = "Standard_D2s_v3"

scale_settings {
min_node_count = 2
max_node_count = 20
scale_down_nodes_after_idle_duration = 30
}

vm_priority = "LowPriority"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.1
resource_usage:
azurerm_machine_learning_compute_cluster.with_monthly_hrs:
monthly_hrs: 100
azurerm_machine_learning_compute_cluster.with_monthly_hrs_zero_min_node_count:
monthly_hrs: 100
azurerm_machine_learning_compute_cluster.with_instances:
instances: 10
azurerm_machine_learning_compute_cluster.with_instances_and_monthly_hrs:
instances: 10
monthly_hrs: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

Name Monthly Qty Unit Monthly Cost

azurerm_machine_learning_compute_instance.example["Standard_D16s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_D16s_v3) 730 hours $700.80

azurerm_machine_learning_compute_instance.example["Standard_D2s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_D2s_v3) 730 hours $87.60

azurerm_machine_learning_compute_instance.example["Standard_D4s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_D4s_v3) 730 hours $175.20

azurerm_machine_learning_compute_instance.example["Standard_D8s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_D8s_v3) 730 hours $350.40

azurerm_machine_learning_compute_instance.example["Standard_DS12_v2"]
└─ Instance usage (Linux, pay as you go, Standard_DS12_v2) 730 hours $276.67

azurerm_machine_learning_compute_instance.example["Standard_E16s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_E16s_v3) 730 hours $934.40

azurerm_machine_learning_compute_instance.example["Standard_E4s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_E4s_v3) 730 hours $233.60

azurerm_machine_learning_compute_instance.example["Standard_E8s_v3"]
└─ Instance usage (Linux, pay as you go, Standard_E8s_v3) 730 hours $467.20

azurerm_machine_learning_compute_instance.example["Standard_F16s_v2"]
└─ Instance usage (Linux, pay as you go, Standard_F16s_v2) 730 hours $566.48

azurerm_machine_learning_compute_instance.example["Standard_F4s_v2"]
└─ Instance usage (Linux, pay as you go, Standard_F4s_v2) 730 hours $141.62

azurerm_machine_learning_compute_instance.example["Standard_F8s_v2"]
└─ Instance usage (Linux, pay as you go, Standard_F8s_v2) 730 hours $283.24

azurerm_machine_learning_compute_instance.example["Standard_NC12"]
└─ Instance usage (Linux, pay as you go, Standard_NC12) 730 hours $1,703.09

azurerm_machine_learning_compute_instance.example["Standard_NC24"]
└─ Instance usage (Linux, pay as you go, Standard_NC24) 730 hours $3,406.18

azurerm_machine_learning_compute_instance.example["Standard_NC6"]
└─ Instance usage (Linux, pay as you go, Standard_NC6) 730 hours $851.18

azurerm_machine_learning_compute_instance.example["Standard_NV12"]
└─ Instance usage (Linux, pay as you go, Standard_NV12) 730 hours $1,992.90

azurerm_machine_learning_compute_instance.example["Standard_NV24"]
└─ Instance usage (Linux, pay as you go, Standard_NV24) 730 hours $3,985.80

azurerm_machine_learning_compute_instance.example["Standard_NV6"]
└─ Instance usage (Linux, pay as you go, Standard_NV6) 730 hours $996.45

azurerm_machine_learning_compute_instance.with_monthly_hrs
└─ Instance usage (Linux, pay as you go, Standard_D2s_v3) 100 hours $12.00

azurerm_storage_account.example
├─ Capacity Monthly cost depends on usage: $0.0392 per GB
├─ Write operations Monthly cost depends on usage: $0.11 per 10k operations
├─ List and create container operations Monthly cost depends on usage: $0.11 per 10k operations
├─ Read operations Monthly cost depends on usage: $0.0043 per 10k operations
├─ All other operations Monthly cost depends on usage: $0.0043 per 10k operations
└─ Blob index Monthly cost depends on usage: $0.075 per 10k tags

OVERALL TOTAL $17,164.81
──────────────────────────────────
21 cloud resources were detected:
∙ 19 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file
∙ 2 were free:
∙ 1 x azurerm_machine_learning_workspace
∙ 1 x azurerm_resource_group

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Project ┃ Monthly cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━┫
┃ TestMachineLearningComputeInstance ┃ $17,165 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━┛