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.52k stars 4.6k forks source link

azurerm_mysql_active_directory_administrator always takes exactly 10 minutes, when it's actually ready after less than 1 minute #9592

Open AdamCoulterOz opened 3 years ago

AdamCoulterOz commented 3 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform v0.13.5 AzureRM v2.38.0

Affected Resource

Terraform Configuration Files

provider "azurerm" {
  features {}
}

data "azurerm_client_config" "current" {}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West US"
}

resource "azurerm_mysql_server" "example" {
  name                         = "example-mysqlserver"
  location                     = azurerm_resource_group.example.location
  resource_group_name          = azurerm_resource_group.example.name
  administrator_login          = "mysqladminun"
  administrator_login_password = "H@Sh1CoR3!"
  sku_name                     = "B_Gen5_2"
  storage_mb                   = 5120
  version                      = "8.0"
  ssl_enforcement_enabled      = false
}

resource "azurerm_mysql_active_directory_administrator" "example" {
  server_name         = azurerm_mysql_server.example.name
  resource_group_name = azurerm_resource_group.example.name
  login               = "sqladmin"
  tenant_id           = data.azurerm_client_config.current.tenant_id
  object_id           = data.azurerm_client_config.current.object_id
}

Debug Output

https://gist.github.com/AdamCoulterOz/a0e2511fe8dfd17a50c3bf9a1d4d1f8b

Expected Behaviour

Resource azurerm_mysql_active_directory_administrator.example should have reported complete in <20 seconds.

Actual Behaviour

Resource azurerm_mysql_active_directory_administrator.example reported complete in exactly 10 minutes, as it always does.

Steps to Reproduce

  1. terraform apply

Important Factoids

Portal screen shot showing user assignment has completed at 6:15:52 pm (to correlate with the attached logs):

Screen Shot 2020-12-01 at 6 15 52 pm

References

@evertonmc this might be something you can help with?

AdamCoulterOz commented 3 years ago

I've found the root cause is the Azure go-autorest library enforces a Retry-After: 600 header returned by the Azure Rest API (600 seconds = my 10 minute issue). However, when using the portal it makes this same request, but it ignores this RetryAfter value and retries every 5 seconds.

What would be a way to work around this until / if the appropriate Azure API team ever updates it?