-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_machine_learning_compute_cluster
- subnet_resource_id
does not have to be specified when node_public_ip_enabled
is false
#28673
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,8 +155,10 @@ func resourceComputeCluster() *pluginsdk.Resource { | |
}, | ||
|
||
"subnet_resource_id": { | ||
Type: pluginsdk.TypeString, | ||
Type: pluginsdk.TypeString, | ||
// NOTE: O+C as you don't have to specify it for Azure to assign one to the cluster | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
}, | ||
|
||
|
@@ -211,28 +213,6 @@ func resourceComputeClusterCreate(d *pluginsdk.ResourceData, meta interface{}) e | |
if !response.WasNotFound(existing.HttpResponse) { | ||
return tf.ImportAsExistsError("azurerm_machine_learning_compute_cluster", id.ID()) | ||
} | ||
nodePublicIPEnabled, ok := d.Get("node_public_ip_enabled").(bool) | ||
if !ok { | ||
return fmt.Errorf("unable to assert type for `node_public_ip_enabled`") | ||
} | ||
|
||
subnetResourceID, ok := d.Get("subnet_resource_id").(string) | ||
if !ok { | ||
return fmt.Errorf("unable to assert type for `subnet_resource_id`") | ||
} | ||
|
||
workspaceInManagedVnet := false | ||
|
||
if workspaceModel.Properties != nil && | ||
workspaceModel.Properties.ManagedNetwork != nil && | ||
workspaceModel.Properties.ManagedNetwork.Status != nil && | ||
workspaceModel.Properties.ManagedNetwork.Status.Status != nil { | ||
workspaceInManagedVnet = *workspaceModel.Properties.ManagedNetwork.Status.Status == workspaces.ManagedNetworkStatusActive | ||
} | ||
|
||
if !nodePublicIPEnabled && subnetResourceID == "" && !workspaceInManagedVnet { | ||
return fmt.Errorf("`subnet_resource_id` must be set if `node_public_ip_enabled` is set to `false` or the workspace is not in a managed network") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last comment, the docs mention this validation for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good shout and done! Thanks @stephybun |
||
} | ||
|
||
vmPriority := machinelearningcomputes.VMPriority(d.Get("vm_priority").(string)) | ||
computeClusterAmlComputeProperties := machinelearningcomputes.AmlComputeProperties{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,21 @@ func TestAccComputeCluster_complete(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccComputeCluster_subnetResourceId(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_machine_learning_compute_cluster", "test") | ||
r := ComputeClusterResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.noSubnetResourceId(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccComputeCluster_recreateVmSize(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_machine_learning_compute_cluster", "test") | ||
r := ComputeClusterResource{} | ||
|
@@ -235,6 +250,48 @@ resource "azurerm_machine_learning_compute_cluster" "test" { | |
`, template, data.RandomIntOfLength(8)) | ||
} | ||
|
||
func (r ComputeClusterResource) noSubnetResourceId(data acceptance.TestData) string { | ||
template := r.template_complete(data) | ||
return fmt.Sprintf(` | ||
%s | ||
variable "ssh_key" { | ||
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt [email protected]" | ||
} | ||
|
||
resource "azurerm_machine_learning_compute_cluster" "test" { | ||
name = "CC-%d" | ||
location = azurerm_resource_group.test.location | ||
vm_priority = "LowPriority" | ||
vm_size = "STANDARD_DS2_V2" | ||
machine_learning_workspace_id = azurerm_machine_learning_workspace.test.id | ||
node_public_ip_enabled = false | ||
description = "Machine Learning" | ||
tags = { | ||
environment = "test" | ||
} | ||
scale_settings { | ||
min_node_count = 0 | ||
max_node_count = 1 | ||
scale_down_nodes_after_idle_duration = "PT30S" # 30 seconds | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
|
||
ssh_public_access_enabled = false | ||
ssh { | ||
admin_username = "adminuser" | ||
key_value = var.ssh_key | ||
} | ||
depends_on = [ | ||
azurerm_subnet_network_security_group_association.test, | ||
azurerm_private_endpoint.test, | ||
] | ||
} | ||
`, template, data.RandomIntOfLength(8)) | ||
} | ||
|
||
func (r ComputeClusterResource) recreateVmSize(data acceptance.TestData) string { | ||
template := r.template_basic(data) | ||
return fmt.Sprintf(` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to confirm that this check isn't still required? Do we have an acceptance test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe my acceptance test covered this check not being needed because nodePublicIPEnabled was false, the subnetResourceID was not specified and the workspace was not in a managed vnet and that test passes