From f89131ef07d7553735c4c19ef4f4538ee9409b60 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Tue, 18 Dec 2018 16:41:28 +0000 Subject: [PATCH 01/23] Adding support for Azure Active Directory resource --- .../resource_arm_service_fabric_cluster.go | 79 ++++++++++++++++++- ...esource_arm_service_fabric_cluster_test.go | 74 +++++++++++++++++ .../r/service_fabric_cluster.html.markdown | 12 +++ 3 files changed, 164 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go index 50686d889797..1a343c50cbad 100644 --- a/azurerm/resource_arm_service_fabric_cluster.go +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -70,7 +70,7 @@ func resourceArmServiceFabricCluster() *schema.Resource { Required: true, ForceNew: true, }, - + "add_on_features": { Type: schema.TypeSet, Optional: true, @@ -78,6 +78,31 @@ func resourceArmServiceFabricCluster() *schema.Resource { Set: schema.HashString, }, + "azure_active_directory": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tenant_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "cluster_application": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "client_application": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + }, + }, + "certificate": { Type: schema.TypeList, Optional: true, @@ -288,6 +313,9 @@ func resourceArmServiceFabricClusterCreate(d *schema.ResourceData, meta interfac addOnFeaturesRaw := d.Get("add_on_features").(*schema.Set).List() addOnFeatures := expandServiceFabricClusterAddOnFeatures(addOnFeaturesRaw) + azureActiveDirectoryRaw := d.Get("azure_active_directory").([]interface{}) + azureActiveDirectory := expandServiceFabricClusterAzureActiveDirectory(azureActiveDirectoryRaw) + certificateRaw := d.Get("certificate").([]interface{}) certificate := expandServiceFabricClusterCertificate(certificateRaw) @@ -308,6 +336,7 @@ func resourceArmServiceFabricClusterCreate(d *schema.ResourceData, meta interfac Tags: expandTags(tags), ClusterProperties: &servicefabric.ClusterProperties{ AddOnFeatures: addOnFeatures, + AzureActiveDirectory: azureActiveDirectory, Certificate: certificate, ClientCertificateThumbprints: clientCertificateThumbprints, DiagnosticsStorageAccountConfig: diagnostics, @@ -445,6 +474,11 @@ func resourceArmServiceFabricClusterRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting `add_on_features`: %+v", err) } + azureActiveDirectory := flattenServiceFabricClusterAzureActiveDirectory(props.AzureActiveDirectory) + if err := d.Set("azure_active_directory", azureActiveDirectory); err != nil { + return fmt.Errorf("Error setting `azure_active_directory`: %+v", err) + } + certificate := flattenServiceFabricClusterCertificate(props.Certificate) if err := d.Set("certificate", certificate); err != nil { return fmt.Errorf("Error setting `certificate`: %+v", err) @@ -509,6 +543,49 @@ func expandServiceFabricClusterAddOnFeatures(input []interface{}) *[]string { return &output } +func expandServiceFabricClusterAzureActiveDirectory(input []interface{}) *servicefabric.AzureActiveDirectory { + if len(input) == 0 { + return nil + } + + v := input[0].(map[string]interface{}) + + tenantId := v["tenant_id"].(string) + clusterApplication := v["cluster_application"].(string) + clientApplication := v["client_application"].(string) + + config := servicefabric.AzureActiveDirectory{ + TenantID: utils.String(tenantId), + ClusterApplication: utils.String(clusterApplication), + ClientApplication: utils.String(clientApplication), + } + return &config +} + +func flattenServiceFabricClusterAzureActiveDirectory(input *servicefabric.AzureActiveDirectory) []interface{} { + results := make([]interface{}, 0) + + if v := input; v != nil { + output := make(map[string]interface{}) + + if name := v.TenantID; name != nil { + output["tenant_id"] = *name + } + + if name := v.ClusterApplication; name != nil { + output["cluster_application"] = *name + } + + if endpoint := v.ClientApplication; endpoint != nil { + output["client_application"] = *endpoint + } + + results = append(results, output) + } + + return results +} + func flattenServiceFabricClusterAddOnFeatures(input *[]string) []interface{} { output := make([]interface{}, 0) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index fd8c6ae44474..187a5db7129c 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -29,6 +29,7 @@ func TestAccAzureRMServiceFabricCluster_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "0"), resource.TestCheckResourceAttr(resourceName, "certificate.#", "0"), resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "0"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "0"), resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"), resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"), @@ -234,6 +235,38 @@ func TestAccAzureRMServiceFabricCluster_readerAdminClientCertificateThumbprint(t }) } +func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricCluster_clientCertificateThumbprint(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.tenant_id", "00000000-0000-0000-0000-00000000000"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), + resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAzureRMServiceFabricCluster_diagnosticsConfig(t *testing.T) { resourceName := "azurerm_service_fabric_cluster.test" ri := acctest.RandInt() @@ -721,6 +754,47 @@ resource "azurerm_service_fabric_cluster" "test" { `, rInt, location, rInt) } +func testAccAzureRMServiceFabricCluster_readerAdminClientCertificateThumbprint(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "https://example:80" + + azure_active_directory { + tenant_id = "00000000-0000-0000-0000-000000000000" + cluster_application = "00000000-0000-0000-0000-000000000000" + client_application = "00000000-0000-0000-0000-000000000000" + } + + fabric_settings { + name = "Security" + + parameters { + "ClusterProtectionLevel" = "EncryptAndSign" + } + } + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt) +} + func testAccAzureRMServiceFabricCluster_diagnosticsConfig(rInt int, rString, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index 330febf18a8b..bef8f138c02d 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -65,6 +65,8 @@ The following arguments are supported: * `add_on_features` - (Optional) A List of one or more features which should be enabled, such as `DnsService`. +* `azure_active_directory` - (Optional) `azure_active_directory` block as defined below. Changing this forces a new resource to be created. + * `certificate` - (Optional) A `certificate` block as defined below. * `client_certificate_thumbprint` - (Optional) One or two `client_certificate_thumbprint` blocks as defined below. @@ -79,6 +81,16 @@ The following arguments are supported: --- +A `azure_active_directory` block supports the following: + +* `tenant_id` - (Required) The TenantID of the Azure Active Directory resource. + +* `cluster_application` - (Required) The GUID of the cluster application. + +* `client_application` - (Required) The GUID of the client application. + +--- + A `certificate` block supports the following: * `thumbprint` - (Required) The Thumbprint of the Certificate. From fd61fc75f31eb88e811e62b69c2e773aa088d0aa Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Wed, 19 Dec 2018 15:23:31 +0000 Subject: [PATCH 02/23] add _id to fields for clarity --- azurerm/resource_arm_service_fabric_cluster.go | 12 ++++++------ azurerm/resource_arm_service_fabric_cluster_test.go | 10 +++++----- website/docs/r/service_fabric_cluster.html.markdown | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go index 1a343c50cbad..14af9e434ae1 100644 --- a/azurerm/resource_arm_service_fabric_cluster.go +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -89,12 +89,12 @@ func resourceArmServiceFabricCluster() *schema.Resource { Required: true, ForceNew: true, }, - "cluster_application": { + "cluster_application_id": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "client_application": { + "client_application_id": { Type: schema.TypeString, Required: true, ForceNew: true, @@ -551,8 +551,8 @@ func expandServiceFabricClusterAzureActiveDirectory(input []interface{}) *servic v := input[0].(map[string]interface{}) tenantId := v["tenant_id"].(string) - clusterApplication := v["cluster_application"].(string) - clientApplication := v["client_application"].(string) + clusterApplication := v["cluster_application_id"].(string) + clientApplication := v["client_application_id"].(string) config := servicefabric.AzureActiveDirectory{ TenantID: utils.String(tenantId), @@ -573,11 +573,11 @@ func flattenServiceFabricClusterAzureActiveDirectory(input *servicefabric.AzureA } if name := v.ClusterApplication; name != nil { - output["cluster_application"] = *name + output["cluster_application_id"] = *name } if endpoint := v.ClientApplication; endpoint != nil { - output["client_application"] = *endpoint + output["client_application_id"] = *endpoint } results = append(results, output) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 187a5db7129c..817eefce9aa9 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -251,8 +251,8 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { testCheckAzureRMServiceFabricClusterExists(resourceName), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.tenant_id", "00000000-0000-0000-0000-00000000000"), - resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application", "00000000-0000-0000-0000-000000000000"), - resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application_id", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application_id", "00000000-0000-0000-0000-000000000000"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), @@ -771,9 +771,9 @@ resource "azurerm_service_fabric_cluster" "test" { management_endpoint = "https://example:80" azure_active_directory { - tenant_id = "00000000-0000-0000-0000-000000000000" - cluster_application = "00000000-0000-0000-0000-000000000000" - client_application = "00000000-0000-0000-0000-000000000000" + tenant_id = "00000000-0000-0000-0000-000000000000" + cluster_application_id = "00000000-0000-0000-0000-000000000000" + client_application_id = "00000000-0000-0000-0000-000000000000" } fabric_settings { diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index bef8f138c02d..efca024198b4 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -85,9 +85,9 @@ A `azure_active_directory` block supports the following: * `tenant_id` - (Required) The TenantID of the Azure Active Directory resource. -* `cluster_application` - (Required) The GUID of the cluster application. +* `cluster_application_id` - (Required) The GUID of the cluster application. -* `client_application` - (Required) The GUID of the client application. +* `client_application_id` - (Required) The GUID of the client application. --- From 04d705d9893a5c7c12c3f8b3731eb944a2c7e66e Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 20 Dec 2018 11:17:33 +0000 Subject: [PATCH 03/23] ran make fmt/make build --- azurerm/resource_arm_service_fabric_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go index 14af9e434ae1..71db55ab7559 100644 --- a/azurerm/resource_arm_service_fabric_cluster.go +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -70,7 +70,7 @@ func resourceArmServiceFabricCluster() *schema.Resource { Required: true, ForceNew: true, }, - + "add_on_features": { Type: schema.TypeSet, Optional: true, From 26e4ea33948f69393297b17bd6e85197a973dcfa Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 20 Dec 2018 11:33:29 +0000 Subject: [PATCH 04/23] changed test function name --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 817eefce9aa9..17fda7fc8549 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -754,7 +754,7 @@ resource "azurerm_service_fabric_cluster" "test" { `, rInt, location, rInt) } -func testAccAzureRMServiceFabricCluster_readerAdminClientCertificateThumbprint(rInt int, location string) string { +func testAccAzureRMServiceFabricCluster_azureActiveDirectory(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" From c3d867f747f4c4e65a3f2b1b8519cf91bbc7bd3e Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 20 Dec 2018 11:46:42 +0000 Subject: [PATCH 05/23] updated line:249 correct function --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 17fda7fc8549..a2dfdfbd119d 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -246,7 +246,7 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMServiceFabricCluster_clientCertificateThumbprint(ri, location), + Config: testAccAzureRMServiceFabricCluster_azureActiveDirectory(ri, location), Check: resource.ComposeTestCheckFunc( testCheckAzureRMServiceFabricClusterExists(resourceName), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), From f905d55252cb7668c26d5ce461b837c82afed257 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 21 Dec 2018 09:52:55 +0000 Subject: [PATCH 06/23] Update website/docs/r/service_fabric_cluster.html.markdown Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- website/docs/r/service_fabric_cluster.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index efca024198b4..5343a0c23944 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -65,7 +65,7 @@ The following arguments are supported: * `add_on_features` - (Optional) A List of one or more features which should be enabled, such as `DnsService`. -* `azure_active_directory` - (Optional) `azure_active_directory` block as defined below. Changing this forces a new resource to be created. +* `azure_active_directory` - (Optional) An `azure_active_directory` block as defined below. Changing this forces a new resource to be created. * `certificate` - (Optional) A `certificate` block as defined below. From 9a27b1ee2c2720b19be68fab07f827ef77c3c981 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 21 Dec 2018 09:53:07 +0000 Subject: [PATCH 07/23] Update website/docs/r/service_fabric_cluster.html.markdown Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- website/docs/r/service_fabric_cluster.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index 5343a0c23944..e7ffdb89b046 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -83,7 +83,7 @@ The following arguments are supported: A `azure_active_directory` block supports the following: -* `tenant_id` - (Required) The TenantID of the Azure Active Directory resource. +* `tenant_id` - (Required) The Azure Active Directory Tenant ID. Changing this forces a new resource to be created. * `cluster_application_id` - (Required) The GUID of the cluster application. From a5b8c8476440a123765f59f8eda52ec6dac75f29 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 21 Dec 2018 09:53:14 +0000 Subject: [PATCH 08/23] Update website/docs/r/service_fabric_cluster.html.markdown Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- website/docs/r/service_fabric_cluster.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index e7ffdb89b046..b166aef335bd 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -87,7 +87,7 @@ A `azure_active_directory` block supports the following: * `cluster_application_id` - (Required) The GUID of the cluster application. -* `client_application_id` - (Required) The GUID of the client application. +* `cluster_application_id` - (Required) The Azure Active Directory Client ID which should be used for the Client Application. Changing this forces a new resource to be created. --- From 935926608ac3af74eb9064e370d28d82b25a8654 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 21 Dec 2018 09:53:22 +0000 Subject: [PATCH 09/23] Update website/docs/r/service_fabric_cluster.html.markdown Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- website/docs/r/service_fabric_cluster.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/service_fabric_cluster.html.markdown b/website/docs/r/service_fabric_cluster.html.markdown index b166aef335bd..76c6f3933a33 100644 --- a/website/docs/r/service_fabric_cluster.html.markdown +++ b/website/docs/r/service_fabric_cluster.html.markdown @@ -85,7 +85,7 @@ A `azure_active_directory` block supports the following: * `tenant_id` - (Required) The Azure Active Directory Tenant ID. Changing this forces a new resource to be created. -* `cluster_application_id` - (Required) The GUID of the cluster application. +* `cluster_application_id` - (Required) The Azure Active Directory Client ID which should be used for the Cluster Application. Changing this forces a new resource to be created. * `cluster_application_id` - (Required) The Azure Active Directory Client ID which should be used for the Client Application. Changing this forces a new resource to be created. From 2b210d31facbd792caccdf6513b733dc578656a6 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Fri, 21 Dec 2018 09:56:32 +0000 Subject: [PATCH 10/23] applying recomendations --- azurerm/resource_arm_service_fabric_cluster.go | 1 + azurerm/resource_arm_service_fabric_cluster_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go index 71db55ab7559..99505884fde9 100644 --- a/azurerm/resource_arm_service_fabric_cluster.go +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -81,6 +81,7 @@ func resourceArmServiceFabricCluster() *schema.Resource { "azure_active_directory": { Type: schema.TypeList, Optional: true, + ForceNew: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index a2dfdfbd119d..e6c1310cec78 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -770,11 +770,11 @@ resource "azurerm_service_fabric_cluster" "test" { vm_image = "Windows" management_endpoint = "https://example:80" - azure_active_directory { - tenant_id = "00000000-0000-0000-0000-000000000000" - cluster_application_id = "00000000-0000-0000-0000-000000000000" - client_application_id = "00000000-0000-0000-0000-000000000000" - } + azure_active_directory { + tenant_id = "00000000-0000-0000-0000-000000000000" + cluster_application_id = "00000000-0000-0000-0000-000000000000" + client_application_id = "00000000-0000-0000-0000-000000000000" + } fabric_settings { name = "Security" From f67ebb336837f321d02d117a9e7064657f7a98d6 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Fri, 21 Dec 2018 10:01:59 +0000 Subject: [PATCH 11/23] applying recomendations --- azurerm/resource_arm_service_fabric_cluster_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index e6c1310cec78..b2fb6d7921db 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -771,9 +771,9 @@ resource "azurerm_service_fabric_cluster" "test" { management_endpoint = "https://example:80" azure_active_directory { - tenant_id = "00000000-0000-0000-0000-000000000000" - cluster_application_id = "00000000-0000-0000-0000-000000000000" - client_application_id = "00000000-0000-0000-0000-000000000000" + tenant_id = "00000000-0000-0000-0000-000000000000" + cluster_application_id = "00000000-0000-0000-0000-000000000000" + client_application_id = "00000000-0000-0000-0000-000000000000" } fabric_settings { From f4f60efda7f8f2cfb0818f1cbabff815cd9292c5 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Fri, 21 Dec 2018 10:04:36 +0000 Subject: [PATCH 12/23] applying recomendations --- azurerm/resource_arm_service_fabric_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go index 99505884fde9..b06733e3c013 100644 --- a/azurerm/resource_arm_service_fabric_cluster.go +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -81,7 +81,7 @@ func resourceArmServiceFabricCluster() *schema.Resource { "azure_active_directory": { Type: schema.TypeList, Optional: true, - ForceNew: true, + ForceNew: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ From 0ab34324844a5c8297f6d62cdc2ed5383ee5ab55 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Mon, 24 Dec 2018 09:18:07 +0000 Subject: [PATCH 13/23] certificate required for AAD to pass tests --- azurerm/resource_arm_service_fabric_cluster_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index b2fb6d7921db..948d1362a1a1 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -249,6 +249,9 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { Config: testAccAzureRMServiceFabricCluster_azureActiveDirectory(ri, location), Check: resource.ComposeTestCheckFunc( testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "certificate.#", "1"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.tenant_id", "00000000-0000-0000-0000-00000000000"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application_id", "00000000-0000-0000-0000-000000000000"), @@ -770,6 +773,11 @@ resource "azurerm_service_fabric_cluster" "test" { vm_image = "Windows" management_endpoint = "https://example:80" + client_certificate_thumbprint { + thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" + is_admin = true + } + azure_active_directory { tenant_id = "00000000-0000-0000-0000-000000000000" cluster_application_id = "00000000-0000-0000-0000-000000000000" From 6fb27872248e6120a2d33bf93ce12d2512bbb069 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Mon, 24 Dec 2018 09:28:45 +0000 Subject: [PATCH 14/23] fixed formating --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 948d1362a1a1..540a4e4d80f8 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -773,7 +773,7 @@ resource "azurerm_service_fabric_cluster" "test" { vm_image = "Windows" management_endpoint = "https://example:80" - client_certificate_thumbprint { + client_certificate_thumbprint { thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" is_admin = true } From 8847de947c0833bc9ee5fb803067361846da0ca1 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 27 Dec 2018 11:08:08 +0000 Subject: [PATCH 15/23] replaced client cert with cert --- azurerm/resource_arm_service_fabric_cluster_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 540a4e4d80f8..18ee8deb140f 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -773,9 +773,9 @@ resource "azurerm_service_fabric_cluster" "test" { vm_image = "Windows" management_endpoint = "https://example:80" - client_certificate_thumbprint { - thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" - is_admin = true + certificate { + thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" + x509_store_name = "My" } azure_active_directory { From 236834d8c5f6fc9ee7cb9a31a72bf09af6d6eacb Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 27 Dec 2018 11:32:59 +0000 Subject: [PATCH 16/23] pull current tenant_id --- azurerm/resource_arm_service_fabric_cluster_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 18ee8deb140f..b3644c03d21c 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -764,6 +764,8 @@ resource "azurerm_resource_group" "test" { location = "%s" } +data "azurerm_client_config" "current" {} + resource "azurerm_service_fabric_cluster" "test" { name = "acctest-%d" resource_group_name = "${azurerm_resource_group.test.name}" @@ -779,7 +781,7 @@ resource "azurerm_service_fabric_cluster" "test" { } azure_active_directory { - tenant_id = "00000000-0000-0000-0000-000000000000" + tenant_id = "${azurerm_client_config.current.tenant_id}" cluster_application_id = "00000000-0000-0000-0000-000000000000" client_application_id = "00000000-0000-0000-0000-000000000000" } From f142f4346e771879bf8b04fee9bc542e1179f787 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Thu, 27 Dec 2018 17:08:53 +0000 Subject: [PATCH 17/23] pull current data tenant_id --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index b3644c03d21c..72aae0cc33bf 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -781,7 +781,7 @@ resource "azurerm_service_fabric_cluster" "test" { } azure_active_directory { - tenant_id = "${azurerm_client_config.current.tenant_id}" + tenant_id = "${data.azurerm_client_config.current.tenant_id}" cluster_application_id = "00000000-0000-0000-0000-000000000000" client_application_id = "00000000-0000-0000-0000-000000000000" } From b15f0801de1458da3ab57845be12f002ed3a2a83 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 28 Dec 2018 09:11:38 +0000 Subject: [PATCH 18/23] Update azurerm/resource_arm_service_fabric_cluster_test.go Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 72aae0cc33bf..2b4727c3efa8 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -253,7 +253,7 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), - resource.TestCheckResourceAttr(resourceName, "azure_active_directory.tenant_id", "00000000-0000-0000-0000-00000000000"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.tenant_id"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application_id", "00000000-0000-0000-0000-000000000000"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application_id", "00000000-0000-0000-0000-000000000000"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), From 85a13e4a490af330df4ebdbb2a8e72bbe6a2ff15 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 28 Dec 2018 09:11:44 +0000 Subject: [PATCH 19/23] Update azurerm/resource_arm_service_fabric_cluster_test.go Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 2b4727c3efa8..3a107667b7f7 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -254,7 +254,7 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.tenant_id"), - resource.TestCheckResourceAttr(resourceName, "azure_active_directory.cluster_application_id", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.cluster_application_id"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application_id", "00000000-0000-0000-0000-000000000000"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), From f3c15407ddc4f01c34c4f8e28d5b88be0fe2d859 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 28 Dec 2018 09:11:51 +0000 Subject: [PATCH 20/23] Update azurerm/resource_arm_service_fabric_cluster_test.go Co-Authored-By: DenheenJ <39860623+DenheenJ@users.noreply.github.com> --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 3a107667b7f7..1528be228bf4 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -255,7 +255,7 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.tenant_id"), resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.cluster_application_id"), - resource.TestCheckResourceAttr(resourceName, "azure_active_directory.client_application_id", "00000000-0000-0000-0000-000000000000"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.client_application_id"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), From d8399e44f3599fab0bb2455217d69bf45f82bc64 Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Fri, 28 Dec 2018 10:05:47 +0000 Subject: [PATCH 21/23] create AAD app resource in tests --- azurerm/resource_arm_service_fabric_cluster_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 1528be228bf4..bd9a3e9bdfb8 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -766,6 +766,15 @@ resource "azurerm_resource_group" "test" { data "azurerm_client_config" "current" {} +resource "azurerm_azuread_application" "test" { + name = "acctestAAD-%d" + homepage = "https://example:80/Explorer/index.html" + identifier_uris = ["https://acctestAAD-app"] + reply_urls = ["https://example"] + available_to_other_tenants = false + oauth2_allow_implicit_flow = true +} + resource "azurerm_service_fabric_cluster" "test" { name = "acctest-%d" resource_group_name = "${azurerm_resource_group.test.name}" @@ -782,7 +791,7 @@ resource "azurerm_service_fabric_cluster" "test" { azure_active_directory { tenant_id = "${data.azurerm_client_config.current.tenant_id}" - cluster_application_id = "00000000-0000-0000-0000-000000000000" + cluster_application_id = "${azurerm_azuread_application.test.application_id}" client_application_id = "00000000-0000-0000-0000-000000000000" } From c88fd0b968ffd6105f707433ce298b4a7fa5985b Mon Sep 17 00:00:00 2001 From: "joseph.denheen" Date: Fri, 28 Dec 2018 10:26:28 +0000 Subject: [PATCH 22/23] create AAD app resource in tests --- azurerm/resource_arm_service_fabric_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index bd9a3e9bdfb8..3967fc041596 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -767,7 +767,7 @@ resource "azurerm_resource_group" "test" { data "azurerm_client_config" "current" {} resource "azurerm_azuread_application" "test" { - name = "acctestAAD-%d" + name = "${azurerm_resource_group.test.name}-AAD" homepage = "https://example:80/Explorer/index.html" identifier_uris = ["https://acctestAAD-app"] reply_urls = ["https://example"] From a10c797397fc5b7aae45de6aacf7ae5eb4c35d77 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 3 Jan 2019 11:29:30 +0000 Subject: [PATCH 23/23] Fixing the broken test --- azurerm/resource_arm_service_fabric_cluster_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go index 3967fc041596..63c0b7c1faaa 100644 --- a/azurerm/resource_arm_service_fabric_cluster_test.go +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -253,9 +253,9 @@ func TestAccAzureRMServiceFabricCluster_azureActiveDirectory(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "1"), - resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.tenant_id"), - resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.cluster_application_id"), - resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.client_application_id"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.0.tenant_id"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.0.cluster_application_id"), + resource.TestCheckResourceAttrSet(resourceName, "azure_active_directory.0.client_application_id"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), @@ -770,7 +770,7 @@ resource "azurerm_azuread_application" "test" { name = "${azurerm_resource_group.test.name}-AAD" homepage = "https://example:80/Explorer/index.html" identifier_uris = ["https://acctestAAD-app"] - reply_urls = ["https://example"] + reply_urls = ["https://acctestAAD-app"] available_to_other_tenants = false oauth2_allow_implicit_flow = true }