hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.48k stars 4.56k forks source link

Unable to refresh storage account state #23240

Closed truekonrads closed 1 week ago

truekonrads commented 10 months ago

Is there an existing issue for this?

Community Note

Terraform Version

v1.5.7

AzureRM Provider Version

v3.60.0

Affected Resource(s)/Data Source(s)

azurerm_storage_account

Terraform Configuration Files

resource "azurerm_storage_account" "mainstore" {
  name                     = "somethingst"
  resource_group_name      = azurerm_resource_group.rg.name
  location                 = azurerm_resource_group.rg.location
  account_tier             = "Standard"
  account_replication_type = "GRS"

  blob_properties {
          change_feed_enabled           = false
        #   change_feed_retention_in_days = 1
          last_access_time_enabled      = false
          versioning_enabled            = false
        }
  timeouts {
    read = "10m"
  }
}

resource "azurerm_role_assignment" "storage_ra1" {
  scope                = azurerm_storage_account.mainstore.id
  role_definition_name = "Storage Blob Data Contributor"
  principal_id         = azurerm_kubernetes_cluster.aks.identity[0].principal_id
  depends_on = [ 
        azurerm_kubernetes_cluster.aks
   ]
}
resource "azurerm_resource_group" "rg" {
  name     = var.global_prefix
  location = var.region
}

Debug Output/Panic Output

terraform plan -refresh-only -target=azurerm_storage_account.mainstore -var-file=defaults.tfvars
azurerm_resource_group.rg: Refreshing state... [id=/subscriptions/0c4c0d8d-df06-4135-b9b7-a844966546ce/resourceGroups/tiportal]
azurerm_storage_account.mainstore: Refreshing state... [id=/subscriptions/0c4c0d8d-df06-4135-b9b7-a844966546ce/resourceGroups/tiportal/providers/Microsoft.Storage/storageAccounts/tiportalst]

#### INDEFINITELY HANGS HERE #####
#### CTRL-C                  #####
Stopping operation...

Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Warning: Resource targeting is in effect
│
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of
│ the changes requested by the current configuration.
│
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from
│ errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
╵
╷
│ Error: reading queue properties for AzureRM Storage Account "tiportalst": queues.Client#GetServiceProperties: Failure sending request: StatusCode=0 -- Original Error: context canceled
│
│   with azurerm_storage_account.mainstore,
│   on storage.tf line 1, in resource "azurerm_storage_account" "mainstore":
│    1: resource "azurerm_storage_account" "mainstore" {
│
╵

Gist: https://gist.github.com/truekonrads/a6e7d35dc13b3f530cabf0a898c836d2

Expected Behaviour

State is refreshed

Actual Behaviour

Indefinitely hangs

Steps to Reproduce

  1. Create the resource (terraform apply)
  2. Refresh the resource (terraform refresh or plan -refresh-only)

Important Factoids

No response

References

No response

truekonrads commented 10 months ago

Revised gist https://gist.github.com/truekonrads/75e1631782a8cc3ccdecb9175a02c40d

magodo commented 10 months ago

It seems blocked during reading the queue properties from its data plane endpoint. Did you have some FW rules that blocked the data plane endpoint somehow?

roelof-adam commented 9 months ago

Is there any update on what caused this? We've had very little fun trying to reconnect to all our storage accounts, and storage accounts where TF state was held due to the unreachable queue endpoint, would be nice to know that the root cause was