Skip to content

Commit

Permalink
Merge pull request #25407 from teowa/stackhci_cluster_clientid
Browse files Browse the repository at this point in the history
`azurerm_stack_hci_cluster` - change `client_id` to `optional`
  • Loading branch information
manicminer authored Mar 27, 2024
2 parents a65cbfb + a216bb5 commit 73ca64f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func resourceArmStackHCICluster() *pluginsdk.Resource {

"client_id": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validation.IsUUID,
},
Expand Down
32 changes: 32 additions & 0 deletions internal/services/azurestackhci/stack_hci_cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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(`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/stack_hci_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 73ca64f

Please sign in to comment.