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

Add public IP option to AzureML Computes #21377

Merged
merged 22 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8221b85
Add identity to iothub data source.
Lucasjuv Dec 5, 2022
31b73c0
Merge remote-tracking branch 'upstream/main'
Lucasjuv Dec 7, 2022
1fff4a6
Merge remote-tracking branch 'upstream/main'
Lucasjuv Dec 7, 2022
8c216a5
Merge remote-tracking branch 'upstream/main'
Lucasjuv Apr 11, 2023
f0d8d79
Add public ip option to azure ML computes.
Lucasjuv Apr 11, 2023
a736df4
Fix comments.
Lucasjuv Apr 13, 2023
2f3ce55
fix property name in the acceptance tests
stephybun Apr 19, 2023
25e2f39
Add private endpoint to tests.
Lucasjuv Apr 19, 2023
95de2b6
Add subresource names.
Lucasjuv Apr 19, 2023
85baccc
Open all traffic on NSG.
Lucasjuv Apr 20, 2023
c7f9737
Add DNS zone configuration.
Lucasjuv May 12, 2023
165c23f
Merge branch 'azureml_compute_public_ip' of https://github.com/Lucasj…
Lucasjuv May 12, 2023
22fb03e
Add fmt arguments.
Lucasjuv May 12, 2023
41dafbc
Merge remote-tracking branch 'upstream/main' into azureml_compute_pub…
Lucasjuv May 12, 2023
1847cd7
Merge remote-tracking branch 'upstream/main' into azureml_compute_pub…
Lucasjuv May 15, 2023
7e6c48c
Fix private dns zone name.
Lucasjuv May 15, 2023
62704bb
Fix private endpoint for cluster.
Lucasjuv May 16, 2023
0a1992f
Change providers to allow Resource group deletion.
Lucasjuv May 17, 2023
b91c9bd
Go back to less permissive NSG
Lucasjuv May 17, 2023
cb3bc9f
Merge branch 'hashicorp:main' into azureml_compute_public_ip
Lucasjuv May 29, 2023
a9e8083
Remove public iip option from compute instance as it isn`t returned yet.
Lucasjuv May 29, 2023
b2dce97
remove RequiresWith for node_public_ip_enabled since it only applies …
stephybun May 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ func resourceComputeCluster() *pluginsdk.Resource {
ForceNew: true,
},

"node_public_ip_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
Lucasjuv marked this conversation as resolved.
Show resolved Hide resolved
ForceNew: true,
RequiredWith: []string{"subnet_resource_id"},
},

"ssh": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -181,6 +189,7 @@ func resourceComputeClusterCreate(d *pluginsdk.ResourceData, meta interface{}) e
VMPriority: &vmPriority,
ScaleSettings: expandScaleSettings(d.Get("scale_settings").([]interface{})),
UserAccountCredentials: expandUserAccountCredentials(d.Get("ssh").([]interface{})),
EnableNodePublicIP: pointer.To(d.Get("node_public_ip_enabled").(bool)),
}

computeClusterAmlComputeProperties.RemoteLoginPortPublicAccess = utils.ToPtr(machinelearningcomputes.RemoteLoginPortPublicAccessDisabled)
Expand Down Expand Up @@ -270,6 +279,7 @@ func resourceComputeClusterRead(d *pluginsdk.ResourceData, meta interface{}) err
d.Set("vm_priority", string(pointer.From(props.VMPriority)))
d.Set("scale_settings", flattenScaleSettings(props.ScaleSettings))
d.Set("ssh", flattenUserAccountCredentials(props.UserAccountCredentials))
d.Set("node_public_ip_enabled", props.EnableNodePublicIP)
if props.Subnet != nil {
d.Set("subnet_resource_id", props.Subnet.Id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ resource "azurerm_machine_learning_compute_cluster" "test" {
vm_size = "STANDARD_DS2_V2"
machine_learning_workspace_id = azurerm_machine_learning_workspace.test.id
subnet_resource_id = azurerm_subnet.test.id
node_public_ip_enabled = false
description = "Machine Learning"
tags = {
environment = "test"
Expand All @@ -225,7 +226,8 @@ resource "azurerm_machine_learning_compute_cluster" "test" {
key_value = var.ssh_key
}
depends_on = [
azurerm_subnet_network_security_group_association.test
azurerm_subnet_network_security_group_association.test,
azurerm_private_endpoint.test,
]
}
`, template, data.RandomIntOfLength(8))
Expand Down Expand Up @@ -367,7 +369,11 @@ resource "azurerm_machine_learning_compute_cluster" "test" {
func (r ComputeClusterResource) template_basic(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down Expand Up @@ -426,7 +432,11 @@ resource "azurerm_machine_learning_workspace" "test" {
func (r ComputeClusterResource) template_complete(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down Expand Up @@ -478,6 +488,37 @@ resource "azurerm_machine_learning_workspace" "test" {
}
}

resource "azurerm_private_dns_zone" "test" {
name = "privatelink.api.azureml.ms"
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "test-vlink"
resource_group_name = azurerm_resource_group.test.name
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
}

resource "azurerm_private_endpoint" "test" {
name = "test-pe-%[6]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
subnet_id = azurerm_subnet.test.id

private_service_connection {
name = "test-mlworkspace-%[7]d"
private_connection_resource_id = azurerm_machine_learning_workspace.test.id
subresource_names = ["amlworkspace"]
is_manual_connection = false
}

private_dns_zone_group {
name = "test"
private_dns_zone_ids = [azurerm_private_dns_zone.test.id]
}
}

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%[6]d"
address_space = ["10.1.0.0/16"]
Expand Down Expand Up @@ -515,5 +556,6 @@ resource "azurerm_subnet_network_security_group_association" "test" {
}
`, data.RandomInteger, data.Locations.Primary,
data.RandomIntOfLength(12), data.RandomIntOfLength(15), data.RandomIntOfLength(16),
data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger,
data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ func resourceComputeInstance() *pluginsdk.Resource {
ForceNew: true,
},

"node_public_ip_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
RequiredWith: []string{"subnet_resource_id"},
},

"ssh": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -192,6 +200,7 @@ func resourceComputeInstanceCreate(d *pluginsdk.ResourceData, meta interface{})
Subnet: subnet,
SshSettings: expandComputeSSHSetting(d.Get("ssh").([]interface{})),
PersonalComputeInstanceSettings: expandComputePersonalComputeInstanceSetting(d.Get("assign_to_user").([]interface{})),
EnableNodePublicIP: pointer.To(d.Get("node_public_ip_enabled").(bool)),
},
ComputeLocation: utils.String(d.Get("location").(string)),
Description: utils.String(d.Get("description").(string)),
Expand Down Expand Up @@ -273,6 +282,7 @@ func resourceComputeInstanceRead(d *pluginsdk.ResourceData, meta interface{}) er
d.Set("authorization_type", string(pointer.From(props.Properties.ComputeInstanceAuthorizationType)))
d.Set("ssh", flattenComputeSSHSetting(props.Properties.SshSettings))
d.Set("assign_to_user", flattenComputePersonalComputeInstanceSetting(props.Properties.PersonalComputeInstanceSettings))
d.Set("node_public_ip_enabled", props.Properties.EnableNodePublicIP)
Lucasjuv marked this conversation as resolved.
Show resolved Hide resolved
}

return tags.FlattenAndSet(d, resp.Model.Tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ resource "azurerm_network_security_group" "test" {
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "29876-44224"
destination_port_range = "29876-29877"
source_address_prefix = "*"
destination_address_prefix = "*"
}
Expand All @@ -180,12 +180,44 @@ resource "azurerm_subnet_network_security_group_association" "test" {
network_security_group_id = azurerm_network_security_group.test.id
}

resource "azurerm_private_dns_zone" "test" {
Lucasjuv marked this conversation as resolved.
Show resolved Hide resolved
name = "privatelink.api.azureml.ms"
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "test" {
name = "test-vlink"
resource_group_name = azurerm_resource_group.test.name
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
}

resource "azurerm_private_endpoint" "test" {
name = "test-pe-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
subnet_id = azurerm_subnet.test.id

private_service_connection {
name = "test-mlworkspace-%d"
private_connection_resource_id = azurerm_machine_learning_workspace.test.id
subresource_names = ["amlworkspace"]
is_manual_connection = false
}

private_dns_zone_group {
name = "test"
private_dns_zone_ids = [azurerm_private_dns_zone.test.id]
}
}

resource "azurerm_machine_learning_compute_instance" "test" {
name = "acctest%d"
location = azurerm_resource_group.test.location
machine_learning_workspace_id = azurerm_machine_learning_workspace.test.id
virtual_machine_size = "STANDARD_DS2_V2"
authorization_type = "personal"
node_public_ip_enabled = false
ssh {
public_key = var.ssh_key
}
Expand All @@ -195,10 +227,11 @@ resource "azurerm_machine_learning_compute_instance" "test" {
Label1 = "Value1"
}
depends_on = [
azurerm_subnet_network_security_group_association.test
azurerm_subnet_network_security_group_association.test,
azurerm_private_endpoint.test,
]
}
`, template, data.RandomIntOfLength(8), data.RandomIntOfLength(8), data.RandomIntOfLength(8))
`, template, data.RandomIntOfLength(8), data.RandomIntOfLength(8), data.RandomIntOfLength(8), data.RandomIntOfLength(8), data.RandomIntOfLength(8))
}

func (r ComputeInstanceResource) requiresImport(data acceptance.TestData) string {
Expand Down Expand Up @@ -287,7 +320,11 @@ resource "azurerm_machine_learning_compute_instance" "test" {
func (r ComputeInstanceResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down Expand Up @@ -338,5 +375,6 @@ resource "azurerm_machine_learning_workspace" "test" {
}
`, data.RandomInteger, data.Locations.Primary,
data.RandomIntOfLength(12), data.RandomIntOfLength(15), data.RandomIntOfLength(16),
data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger,
data.RandomInteger, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ resource "azurerm_machine_learning_inference_cluster" "test" {
func (r InferenceClusterResource) template(data acceptance.TestData, vmSize string, nodeCount int) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down Expand Up @@ -468,7 +472,11 @@ resource "azurerm_kubernetes_cluster" "test" {
func (r InferenceClusterResource) privateTemplate(data acceptance.TestData, vmSize string, nodeCount int) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ resource "azurerm_machine_learning_synapse_spark" "test" {
func (r SynapseSparkResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ The following arguments are supported:

* `local_auth_enabled` - (Optional) Whether local authentication methods is enabled. Defaults to `true`. Changing this forces a new Machine Learning Compute Cluster to be created.

* `node_public_ip_enabled` - (Optional) Whether the compute cluster 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.

* `ssh_public_access_enabled` - (Optional) A boolean value indicating whether enable the public SSH port. Changing this forces a new Machine Learning Compute Cluster to be created.

* `subnet_resource_id` - (Optional) The ID of the Subnet that the Compute Cluster should reside in. Changing this forces a new Machine Learning Compute Cluster to be created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ The following arguments are supported:

* `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.

* `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.

* `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.
Expand Down