diff --git a/internal/services/azurestackhci/stack_hci_cluster_resource.go b/internal/services/azurestackhci/stack_hci_cluster_resource.go index 05bced780b41..ef93d04b329f 100644 --- a/internal/services/azurestackhci/stack_hci_cluster_resource.go +++ b/internal/services/azurestackhci/stack_hci_cluster_resource.go @@ -58,7 +58,7 @@ func resourceArmStackHCICluster() *pluginsdk.Resource { "client_id": { Type: pluginsdk.TypeString, - Required: true, + Optional: true, ForceNew: true, ValidateFunc: validation.IsUUID, }, diff --git a/internal/services/azurestackhci/stack_hci_cluster_resource_test.go b/internal/services/azurestackhci/stack_hci_cluster_resource_test.go index ac26ba82834a..d27959367a97 100644 --- a/internal/services/azurestackhci/stack_hci_cluster_resource_test.go +++ b/internal/services/azurestackhci/stack_hci_cluster_resource_test.go @@ -37,6 +37,24 @@ func TestAccStackHCICluster_basic(t *testing.T) { }) } +func TestAccStackHCICluster_basicWithoutClientId(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_stack_hci_cluster", "test") + r := StackHCIClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basicWithoutClientId(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("cloud_id").IsNotEmpty(), + check.That(data.ResourceName).Key("service_endpoint").IsNotEmpty(), + check.That(data.ResourceName).Key("resource_provider_object_id").IsNotEmpty(), + ), + }, + data.ImportStep(), + }) +} + func TestAccStackHCICluster_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_stack_hci_cluster", "test") r := StackHCIClusterResource{} @@ -178,6 +196,20 @@ func (r StackHCIClusterResource) Exists(ctx context.Context, client *clients.Cli return utils.Bool(resp.Model != nil), nil } +func (r StackHCIClusterResource) basicWithoutClientId(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_stack_hci_cluster" "test" { + name = "acctest-StackHCICluster-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + tenant_id = data.azurerm_client_config.current.tenant_id +} +`, template, data.RandomInteger) +} + func (r StackHCIClusterResource) basic(data acceptance.TestData) string { template := r.template(data) return fmt.Sprintf(` diff --git a/website/docs/r/stack_hci_cluster.html.markdown b/website/docs/r/stack_hci_cluster.html.markdown index e5bd9734d3ce..29d5e4677bb6 100644 --- a/website/docs/r/stack_hci_cluster.html.markdown +++ b/website/docs/r/stack_hci_cluster.html.markdown @@ -46,7 +46,7 @@ The following arguments are supported: * `location` - (Required) The Azure Region where the Azure Stack HCI Cluster should exist. Changing this forces a new resource to be created. -* `client_id` - (Required) The Client ID of the Azure Active Directory which is used by the Azure Stack HCI Cluster. Changing this forces a new resource to be created. +* `client_id` - (Optional) The Client ID of the Azure Active Directory Application which is used by the Azure Stack HCI Cluster. Changing this forces a new resource to be created. * `identity` - (Optional) An `identity` block as defined below.