diff --git a/cmd/debug/readme.md b/cmd/debug/readme.md index 943688ef6b9b..71127e1ef12b 100644 --- a/cmd/debug/readme.md +++ b/cmd/debug/readme.md @@ -3,7 +3,7 @@ To debug the provider ## VSCODE -create debug config: +create debug config in VSCODE: ```json @@ -50,5 +50,34 @@ provider_installation { ```sh export TF_CLI_CONFIG_FILE=/Users/ricardol/git/terraform-provider-azurerm/tmp/ex1/terraformrc +# In terminal 1 there's the value this variable should have export TF_REATTACH_PROVIDERS=.... ``` + + +In a new folder, create a `provider.tf` with: +``` +terraform { + required_providers { + azurerm = { + source = "snyk/azurerm" + # version = "=3.0.0" + } + } +} + +provider "azurerm" { + features {} +} +``` + +Create a `main.tf` with: +``` +resource "azurerm_storage_account" "mysa" { +} +``` + +Run in the shell: +``` +terraform import azurerm_storage_account.mysa "/subscriptions/ec86c868-4762-493c-ae65-411f88b2ffab/resourceGroups/rleal-resources/providers/Microsoft.Storage/storageAccounts/rlealstoraccount" +``` diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 5877d34c2ce1..6177052aa979 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -2117,21 +2117,22 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err } } - if supportLevel.supportQueue { - queueClient, err := storageClient.QueuesClient(ctx, *account) - if err != nil { - return fmt.Errorf("building Queues Client: %s", err) - } - - queueProps, err := queueClient.GetServiceProperties(ctx, account.ResourceGroup, id.Name) - if err != nil { - return fmt.Errorf("reading queue properties for AzureRM Storage Account %q: %+v", id.Name, err) - } - - if err := d.Set("queue_properties", flattenQueueProperties(queueProps)); err != nil { - return fmt.Errorf("setting `queue_properties`: %+v", err) - } - } + // We need access to keys to create a storageClient.QueuesClient + // if supportLevel.supportQueue { + // queueClient, err := storageClient.QueuesClient(ctx, *account) + // if err != nil { + // return fmt.Errorf("building Queues Client: %s", err) + // } + + // queueProps, err := queueClient.GetServiceProperties(ctx, account.ResourceGroup, id.Name) + // if err != nil { + // return fmt.Errorf("reading queue properties for AzureRM Storage Account %q: %+v", id.Name, err) + // } + + // if err := d.Set("queue_properties", flattenQueueProperties(queueProps)); err != nil { + // return fmt.Errorf("setting `queue_properties`: %+v", err) + // } + // } if supportLevel.supportShare { fileServiceClient := storageClient.FileServicesClient @@ -2147,29 +2148,30 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err } } - if supportLevel.supportStaticWebsite { - storageClient := meta.(*clients.Client).Storage - account, err := storageClient.FindAccount(ctx, id.Name) - if err != nil { - return fmt.Errorf("retrieving Account %q: %s", id.Name, err) - } - - accountsClient, err := storageClient.AccountsDataPlaneClient(ctx, *account) - if err != nil { - return fmt.Errorf("building Accounts Data Plane Client: %s", err) - } - - staticWebsiteProps, err := accountsClient.GetServiceProperties(ctx, id.Name) - if err != nil { - if staticWebsiteProps.Response.Response != nil && !utils.ResponseWasNotFound(staticWebsiteProps.Response) { - return fmt.Errorf("reading static website for AzureRM Storage Account %q: %+v", id.Name, err) - } - } - staticWebsite := flattenStaticWebsiteProperties(staticWebsiteProps) - if err := d.Set("static_website", staticWebsite); err != nil { - return fmt.Errorf("setting `static_website `for AzureRM Storage Account %q: %+v", id.Name, err) - } - } + // We need access to keys to create a storageClient.AccountsDataPlaneClient + // if supportLevel.supportStaticWebsite { + // storageClient := meta.(*clients.Client).Storage + // account, err := storageClient.FindAccount(ctx, id.Name) + // if err != nil { + // return fmt.Errorf("retrieving Account %q: %s", id.Name, err) + // } + + // accountsClient, err := storageClient.AccountsDataPlaneClient(ctx, *account) + // if err != nil { + // return fmt.Errorf("building Accounts Data Plane Client: %s", err) + // } + + // staticWebsiteProps, err := accountsClient.GetServiceProperties(ctx, id.Name) + // if err != nil { + // if staticWebsiteProps.Response.Response != nil && !utils.ResponseWasNotFound(staticWebsiteProps.Response) { + // return fmt.Errorf("reading static website for AzureRM Storage Account %q: %+v", id.Name, err) + // } + // } + // staticWebsite := flattenStaticWebsiteProperties(staticWebsiteProps) + // if err := d.Set("static_website", staticWebsite); err != nil { + // return fmt.Errorf("setting `static_website `for AzureRM Storage Account %q: %+v", id.Name, err) + // } + // } return tags.FlattenAndSet(d, resp.Tags) }