diff --git a/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource.go b/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource.go index 062386f83c86..517cc7ceb217 100644 --- a/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource.go +++ b/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource.go @@ -6,7 +6,6 @@ package azurestackhci import ( "context" "fmt" - "log" "regexp" "time" @@ -194,11 +193,6 @@ func (r StackHCIMarketplaceGalleryImageResource) Create() sdk.ResourceFunc { return fmt.Errorf("performing create %s: %+v", id, err) } - // https://github.com/Azure/azure-rest-api-specs/issues/31876 - if err := resourceMarketplaceGalleryImageWaitForCreated(ctx, *client, id); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - metadata.SetID(id) return nil @@ -336,42 +330,3 @@ func flattenStackHCIMarketplaceGalleryImageIdentifier(input *marketplacegalleryi }, } } - -func resourceMarketplaceGalleryImageWaitForCreated(ctx context.Context, client marketplacegalleryimages.MarketplaceGalleryImagesClient, id marketplacegalleryimages.MarketplaceGalleryImageId) error { - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("internal error: context had no deadline") - } - - state := &pluginsdk.StateChangeConf{ - MinTimeout: 10 * time.Second, - ContinuousTargetOccurence: 3, - Pending: []string{"NotFound"}, - Target: []string{"Found"}, - Refresh: resourceMarketplaceGalleryImageRefreshFunc(ctx, client, id), - Timeout: time.Until(deadline), - } - - if _, err := state.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - - return nil -} - -func resourceMarketplaceGalleryImageRefreshFunc(ctx context.Context, client marketplacegalleryimages.MarketplaceGalleryImagesClient, id marketplacegalleryimages.MarketplaceGalleryImageId) pluginsdk.StateRefreshFunc { - return func() (interface{}, string, error) { - log.Printf("[DEBUG] Checking status for %s ..", id) - - resp, err := client.Get(ctx, id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return resp, "NotFound", nil - } - - return resp, "Error", fmt.Errorf("retrieving %s: %+v", id, err) - } - - return resp, "Found", nil - } -} diff --git a/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource_test.go b/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource_test.go index 00aed136f837..5e5fdf8e082b 100644 --- a/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource_test.go +++ b/internal/services/azurestackhci/stack_hci_marketplace_gallery_image_resource_test.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copy// Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 package azurestackhci_test @@ -165,10 +165,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "test" { sku = "2022-datacenter-azure-edition-core" } - lifecycle { - ignore_changes = [storage_path_id] - } - depends_on = [azurerm_role_assignment.test] } `, template, data.RandomString, os.Getenv(customLocationIdEnv), r.imageVersion) @@ -193,10 +189,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "import" { offer = azurerm_stack_hci_marketplace_gallery_image.test.identifier.0.offer sku = azurerm_stack_hci_marketplace_gallery_image.test.identifier.0.sku } - - lifecycle { - ignore_changes = [storage_path_id] - } } `, config) } @@ -232,8 +224,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "test" { offer = "WindowsServer" sku = "2022-datacenter-azure-edition-core" } - - depends_on = [azurerm_role_assignment.test] } `, template, data.RandomString, os.Getenv(customLocationIdEnv), r.imageVersion) } @@ -272,8 +262,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "test" { tags = { foo = "bar" } - - depends_on = [azurerm_role_assignment.test] } `, template, data.RandomString, os.Getenv(customLocationIdEnv), r.imageVersion) } @@ -313,8 +301,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "test" { foo = "bar" env = "test" } - - depends_on = [azurerm_role_assignment.test] } `, template, data.RandomString, os.Getenv(customLocationIdEnv), r.imageVersion) } @@ -326,6 +312,8 @@ resource "azurerm_resource_group" "test" { location = "%s" } +data "azurerm_client_config" "test" {} + // service principal of 'Microsoft.AzureStackHCI Resource Provider' data "azuread_service_principal" "hciRp" { client_id = "1412d89f-b8a8-4111-b4fd-e82905cbd85d" diff --git a/internal/services/azurestackhci/stack_hci_network_interface_resource.go b/internal/services/azurestackhci/stack_hci_network_interface_resource.go index 49c6d3d580f8..49f197f78c39 100644 --- a/internal/services/azurestackhci/stack_hci_network_interface_resource.go +++ b/internal/services/azurestackhci/stack_hci_network_interface_resource.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright (c)// Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 package azurestackhci @@ -6,7 +6,6 @@ package azurestackhci import ( "context" "fmt" - "log" "regexp" "time" @@ -182,11 +181,6 @@ func (r StackHCINetworkInterfaceResource) Create() sdk.ResourceFunc { return fmt.Errorf("performing create %s: %+v", id, err) } - // https://github.com/Azure/azure-rest-api-specs/issues/31876 - if err := resourceNetworkInterfaceWaitForCreated(ctx, *client, id); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - metadata.SetID(id) return nil @@ -358,42 +352,3 @@ func flattenStackHCINetworkInterfaceIPConfiguration(input *[]networkinterfaces.I return results, nil } - -func resourceNetworkInterfaceWaitForCreated(ctx context.Context, client networkinterfaces.NetworkInterfacesClient, id networkinterfaces.NetworkInterfaceId) error { - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("internal error: context had no deadline") - } - - state := &pluginsdk.StateChangeConf{ - MinTimeout: 10 * time.Second, - ContinuousTargetOccurence: 4, - Pending: []string{"NotFound"}, - Target: []string{"Found"}, - Refresh: resourceNetworkInterfaceRefreshFunc(ctx, client, id), - Timeout: time.Until(deadline), - } - - if _, err := state.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - - return nil -} - -func resourceNetworkInterfaceRefreshFunc(ctx context.Context, client networkinterfaces.NetworkInterfacesClient, id networkinterfaces.NetworkInterfaceId) pluginsdk.StateRefreshFunc { - return func() (interface{}, string, error) { - log.Printf("[DEBUG] Checking status for %s ..", id) - - resp, err := client.Get(ctx, id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return resp, "NotFound", nil - } - - return resp, "Error", fmt.Errorf("retrieving %s: %+v", id, err) - } - - return resp, "Found", nil - } -} diff --git a/internal/services/azurestackhci/stack_hci_network_interface_resource_test.go b/internal/services/azurestackhci/stack_hci_network_interface_resource_test.go index c82ea6871df6..15365695612e 100644 --- a/internal/services/azurestackhci/stack_hci_network_interface_resource_test.go +++ b/internal/services/azurestackhci/stack_hci_network_interface_resource_test.go @@ -163,7 +163,7 @@ resource "azurerm_stack_hci_network_interface" "test" { } lifecycle { - ignore_changes = [mac_address, ip_configuration.0.private_ip_address] + ignore_changes = [mac_address] } } `, template, data.RandomString, os.Getenv(customLocationIdEnv)) @@ -184,10 +184,6 @@ resource "azurerm_stack_hci_network_interface" "import" { ip_configuration { subnet_id = azurerm_stack_hci_network_interface.test.ip_configuration.0.subnet_id } - - lifecycle { - ignore_changes = [mac_address, ip_configuration.0.private_ip_address] - } } `, config) } diff --git a/internal/services/azurestackhci/stack_hci_virtual_hard_disk_resource.go b/internal/services/azurestackhci/stack_hci_virtual_hard_disk_resource.go index 34af6f6219e7..0c8f022d3050 100644 --- a/internal/services/azurestackhci/stack_hci_virtual_hard_disk_resource.go +++ b/internal/services/azurestackhci/stack_hci_virtual_hard_disk_resource.go @@ -6,7 +6,6 @@ package azurestackhci import ( "context" "fmt" - "log" "regexp" "time" @@ -210,11 +209,6 @@ func (r StackHCIVirtualHardDiskResource) Create() sdk.ResourceFunc { return fmt.Errorf("performing create %s: %+v", id, err) } - // https://github.com/Azure/azure-rest-api-specs/issues/31876 - if err := resourceVirtualHardDiskWaitForCreated(ctx, *client, id); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - metadata.SetID(id) return nil @@ -325,42 +319,3 @@ func (r StackHCIVirtualHardDiskResource) Delete() sdk.ResourceFunc { }, } } - -func resourceVirtualHardDiskWaitForCreated(ctx context.Context, client virtualharddisks.VirtualHardDisksClient, id virtualharddisks.VirtualHardDiskId) error { - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("internal error: context had no deadline") - } - - state := &pluginsdk.StateChangeConf{ - MinTimeout: 10 * time.Second, - ContinuousTargetOccurence: 4, - Pending: []string{"NotFound"}, - Target: []string{"Found"}, - Refresh: resourceVirtualHardDiskRefreshFunc(ctx, client, id), - Timeout: time.Until(deadline), - } - - if _, err := state.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for %s to be created: %+v", id, err) - } - - return nil -} - -func resourceVirtualHardDiskRefreshFunc(ctx context.Context, client virtualharddisks.VirtualHardDisksClient, id virtualharddisks.VirtualHardDiskId) pluginsdk.StateRefreshFunc { - return func() (interface{}, string, error) { - log.Printf("[DEBUG] Checking status for %s ..", id) - - resp, err := client.Get(ctx, id) - if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return resp, "NotFound", nil - } - - return resp, "Error", fmt.Errorf("retrieving %s: %+v", id, err) - } - - return resp, "Found", nil - } -} diff --git a/website/docs/r/stack_hci_marketplace_gallery_image.html.markdown b/website/docs/r/stack_hci_marketplace_gallery_image.html.markdown index 568cc8aed870..f3a681ebd109 100644 --- a/website/docs/r/stack_hci_marketplace_gallery_image.html.markdown +++ b/website/docs/r/stack_hci_marketplace_gallery_image.html.markdown @@ -48,7 +48,6 @@ resource "azurerm_stack_hci_marketplace_gallery_image" "example" { foo = "bar" env = "example" } - depends_on = [azurerm_role_assignment.example] } ``` @@ -76,8 +75,6 @@ The following arguments are supported: * `storage_path_id` - (Optional) The ID of the Azure Stack HCI Storage Path used for this Marketplace Gallery Image. Changing this forces a new Azure Stack HCI Virtual Hard Disk to be created. --> **Note:** If `storage_path_id` is not specified, it will be assigned by the server. If you experience a diff you may need to add this to `ignore_changes`. - * `tags` - (Optional) A mapping of tags which should be assigned to the Azure Stack HCI Marketplace Gallery Image. --- @@ -92,7 +89,7 @@ An `identifier` block supports the following: ## Attributes Reference -In addition to the Arguments listed above - the following Attributes are exported: +In addition to the Arguments listed above - the following Attributes are exported: * `id` - The ID of the Azure Stack HCI Marketplace Gallery Image. diff --git a/website/docs/r/stack_hci_network_interface.html.markdown b/website/docs/r/stack_hci_network_interface.html.markdown index 264a4abd60bc..01709b058055 100644 --- a/website/docs/r/stack_hci_network_interface.html.markdown +++ b/website/docs/r/stack_hci_network_interface.html.markdown @@ -94,8 +94,6 @@ An `ip_configuration` block supports the following: * `private_ip_address` - (Optional) The IPv4 address of the IP configuration. Changing this forces a new resource to be created. --> **Note:** If `private_ip_address` is not specified, it will be assigned by the server. If you experience a diff you may need to add this to `ignore_changes`. - ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: diff --git a/website/docs/r/stack_hci_virtual_hard_disk.html.markdown b/website/docs/r/stack_hci_virtual_hard_disk.html.markdown index 059d61d1d357..1d156f3a6a2a 100644 --- a/website/docs/r/stack_hci_virtual_hard_disk.html.markdown +++ b/website/docs/r/stack_hci_virtual_hard_disk.html.markdown @@ -72,13 +72,13 @@ The following arguments are supported: * `storage_path_id` - (Optional) The ID of the Azure Stack HCI Storage Path used for this Virtual Hard Disk. Changing this forces a new Azure Stack HCI Virtual Hard Disk to be created. --> **Note:** If `storage_path_id` is not specified, it will be assigned by the server. If you experience a diff you may need to add this to `ignore_changes`. +-> **Note:** If `storage_path_id` is not specified, the Virtual Hard Disk will be placed in a high availability Storage Path. If you experience a diff you may need to add this to `ignore_changes`. * `tags` - (Optional) A mapping of tags which should be assigned to the Azure Stack HCI Virtual Hard Disk. ## Attributes Reference -In addition to the Arguments listed above - the following Attributes are exported: +In addition to the Arguments listed above - the following Attributes are exported: * `id` - The ID of the Azure Stack HCI Virtual Hard Disk.