Manages a Machine Learning Compute Instance.
data "azurerm_client_config" "current" {}
resource "azurerm_resource_group" "example" {
name = "example-rg"
location = "west europe"
tags = {
"stage" = "example"
}
}
resource "azurerm_application_insights" "example" {
name = "example-ai"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
application_type = "web"
}
resource "azurerm_key_vault" "example" {
name = "example-kv"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
purge_protection_enabled = true
}
resource "azurerm_storage_account" "example" {
name = "examplesa"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_machine_learning_workspace" "example" {
name = "example-mlw"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
application_insights_id = azurerm_application_insights.example.id
key_vault_id = azurerm_key_vault.example.id
storage_account_id = azurerm_storage_account.example.id
identity {
type = "SystemAssigned"
}
}
resource "azurerm_virtual_network" "example" {
name = "example-vnet"
address_space = ["10.1.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "example" {
name = "example-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.1.0.0/24"]
}
variable "ssh_key" {
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld"
}
resource "azurerm_machine_learning_compute_instance" "example" {
name = "example"
machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
virtual_machine_size = "STANDARD_DS2_V2"
authorization_type = "personal"
ssh {
public_key = var.ssh_key
}
subnet_resource_id = azurerm_subnet.example.id
description = "foo"
tags = {
foo = "bar"
}
}
The following arguments are supported:
name
- (Required) The name which should be used for this Machine Learning Compute Instance. Changing this forces a new Machine Learning Compute Instance to be created.
machine_learning_workspace_id
- (Required) The ID of the Machine Learning Workspace. Changing this forces a new Machine Learning Compute Instance to be created.
virtual_machine_size
- (Required) The Virtual Machine Size. Changing this forces a new Machine Learning Compute Instance to be created.
location
- (Optional) The Azure Region where the Machine Learning Compute Instance should exist.authorization_type
- (Optional) The Compute Instance Authorization type. Possible values include: personal
. Changing this forces a new Machine Learning Compute Instance to be created.
assign_to_user
- (Optional) A assign_to_user
block as defined below. A user explicitly assigned to a personal compute instance. Changing this forces a new Machine Learning Compute Instance to be created.
description
- (Optional) The description of the Machine Learning Compute Instance. Changing this forces a new Machine Learning Compute Instance to be created.
identity
- (Optional) An identity
block as defined below. Changing this forces a new Machine Learning Compute Instance to be created.
local_auth_enabled
- (Optional) Whether local authentication methods is enabled. Defaults to true
. Changing this forces a new Machine Learning Compute Instance to be created.
ssh
- (Optional) A ssh
block as defined below. Specifies policy and settings for SSH access. Changing this forces a new Machine Learning Compute Instance to be created.
subnet_resource_id
- (Optional) Virtual network subnet resource ID the compute nodes belong to. Changing this forces a new Machine Learning Compute Instance to be created.
node_public_ip_enabled
- (Optional) Whether the compute instance will have a public ip. To set this to false a subnet_resource_id
needs to be set. Defaults to true
. Changing this forces a new Machine Learning Compute Cluster to be created.
tags
- (Optional) A mapping of tags which should be assigned to the Machine Learning Compute Instance. Changing this forces a new Machine Learning Compute Instance to be created.
An identity
block supports the following:
type
- (Required) Specifies the type of Managed Service Identity that should be configured on this Machine Learning Compute Instance. Possible values are SystemAssigned
, UserAssigned
, SystemAssigned, UserAssigned
(to enable both). Changing this forces a new resource to be created.
identity_ids
- (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Machine Learning Compute Instance. Changing this forces a new resource to be created.
A assign_to_user
block supports the following:
object_id
- (Optional) User’s AAD Object Id.
tenant_id
- (Optional) User’s AAD Tenant Id.
A ssh
block supports the following:
public_key
- (Required) Specifies the SSH rsa public key file as a string. Use "ssh-keygen -t rsa -b 2048" to generate your SSH key pairs.In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the Machine Learning Compute Instance.
identity
- An identity
block as defined below, which contains the Managed Service Identity information for this Machine Learning Compute Instance.
ssh
- An ssh
block as defined below, which specifies policy and settings for SSH access for this Machine Learning Compute Instance.
A identity
block exports the following:
principal_id
- The Principal ID for the Service Principal associated with the Managed Service Identity of this Machine Learning Compute Instance.
tenant_id
- The Tenant ID for the Service Principal associated with the Managed Service Identity of this Machine Learning Compute Instance.
A ssh
block exports the following:
username
- The admin username of this Machine Learning Compute Instance.
port
- Describes the port for connecting through SSH.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Machine Learning Compute Instance.read
- (Defaults to 5 minutes) Used when retrieving the Machine Learning Compute Instance.delete
- (Defaults to 30 minutes) Used when deleting the Machine Learning Compute Instance.Machine Learning Compute Instances can be imported using the resource id
, e.g.
terraform import azurerm_machine_learning_compute_instance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/compute1