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

azurerm_machine_learning_inference_cluster - support for the ssl.leaf_domain_label and ssl. overwrite_existing_domain properties #11830

Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,39 @@ func resourceAksInferenceCluster() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cert": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
ConflictsWith: []string{"ssl.0.leaf_domain_label", "ssl.0.overwrite_existing_domain"},
},
"key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
ConflictsWith: []string{"ssl.0.leaf_domain_label", "ssl.0.overwrite_existing_domain"},
},
"cname": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
ConflictsWith: []string{"ssl.0.leaf_domain_label", "ssl.0.overwrite_existing_domain"},
},
"leaf_domain_label": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
ConflictsWith: []string{"ssl.0.cert", "ssl.0.key", "ssl.0.cname"},
},
"overwrite_existing_domain": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: "",
ConflictsWith: []string{"ssl.0.cert", "ssl.0.key", "ssl.0.cname"},
},
},
},
Expand Down Expand Up @@ -277,10 +294,17 @@ func expandSSLConfig(input []interface{}) *machinelearningservices.SslConfigurat
sslStatus = "Enabled"
}

if !(v["leaf_domain_label"].(string) == "") {
sslStatus = "Auto"
v["cname"] = ""
}

return &machinelearningservices.SslConfiguration{
Status: machinelearningservices.Status1(sslStatus),
Cert: utils.String(v["cert"].(string)),
Key: utils.String(v["key"].(string)),
Cname: utils.String(v["cname"].(string)),
Status: machinelearningservices.Status1(sslStatus),
Cert: utils.String(v["cert"].(string)),
Key: utils.String(v["key"].(string)),
Cname: utils.String(v["cname"].(string)),
LeafDomainLabel: utils.String(v["leaf_domain_label"].(string)),
OverwriteExistingDomain: utils.Bool(v["overwrite_existing_domain"].(bool)),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,28 @@ func TestAccInferenceCluster_requiresImport(t *testing.T) {
})
}

func TestAccInferenceCluster_complete(t *testing.T) {
func TestAccInferenceCluster_completeCustomSSL(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_machine_learning_inference_cluster", "test")
r := InferenceClusterResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.complete(data),
Config: r.completeCustomSSL(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("ssl"),
})
}

func TestAccInferenceCluster_completeMicrosoftSSL(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_machine_learning_inference_cluster", "test")
r := InferenceClusterResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.completeMicrosoftSSL(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -113,7 +128,7 @@ resource "azurerm_machine_learning_inference_cluster" "test" {
`, r.templateDevTest(data), data.RandomIntOfLength(8))
}

func (r InferenceClusterResource) complete(data acceptance.TestData) string {
func (r InferenceClusterResource) completeCustomSSL(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

Expand All @@ -132,7 +147,28 @@ resource "azurerm_machine_learning_inference_cluster" "test" {
tags = {
ENV = "Test"
}
}
`, r.templateDevTest(data), data.RandomIntOfLength(8))
}

func (r InferenceClusterResource) completeMicrosoftSSL(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_machine_learning_inference_cluster" "test" {
name = "AIC-%d"
machine_learning_workspace_id = azurerm_machine_learning_workspace.test.id
location = azurerm_resource_group.test.location
kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id
cluster_purpose = "DevTest"
ssl {
leaf_domain_label = "contoso"
overwrite_existing_domain = true
}

tags = {
ENV = "Test"
}
}
`, r.templateDevTest(data), data.RandomIntOfLength(8))
}
Expand All @@ -156,7 +192,6 @@ resource "azurerm_machine_learning_inference_cluster" "test" {
tags = {
ENV = "Production"
}

}
`, r.templateFastProd(data), data.RandomIntOfLength(8))
}
Expand Down