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

Planning failed. Terraform encountered an error while generating this plan. ╷ │ Error: making Read request on AzureRM Application Insights Billing Feature #27248

Open omkaracharya17 opened 2 weeks ago

omkaracharya17 commented 2 weeks ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.5

AzureRM Provider Version

2.99.0

Affected Resource(s)/Data Source(s)

azurerm_application_insights

Terraform Configuration Files

data "azurerm_log_analytics_workspace" "log-analytics" {
  name                      = var.workspace_name
  resource_group_name       = var.global_resource_group
}

resource "azurerm_application_insights" "app-insights" {
  for_each                  = var.apps_insights
  name                      = format("poh-%s-%s-%s-%s-%s-ai",
                                      var.environment_code, each.key, 
                                      each.value.customername, each.value.customerenvironment, 
                                      each.value.location)
                            #poh-{env#}-{IDNTenantID}-{ClientCode}-{ClientEnv}-{location}-ai
  resource_group_name       = var.resource_group_name
  location                  = each.value.location
  application_type          = "web"
  workspace_id              = data.azurerm_log_analytics_workspace.log-analytics.id

  tags                      = merge(tomap({"AZTYPE" = "ai"}), var.tags[each.key])

  lifecycle {
    ignore_changes = [ tags ]
  }
}

Debug Output/Panic Output

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

╷
│ Error: making Read request on AzureRM Application Insights Billing Feature 'poh-4-0416c968-a41f-450b-8ac5-d7e1ca6354c3-adbcs-DEV-eastus2-ai': insights.ComponentCurrentBillingFeaturesClient#Get: Failure sending request: StatusCode=504 -- Original Error: context deadline exceeded
│ 
│   with module.environment-group.azurerm_application_insights.app-insights["0416c968-a41f-450b-8ac5-d7e1ca6354c3"],
│   on ../../modules/environment-group/app-insight.tf line 6, in resource "azurerm_application_insights" "app-insights":
│    6: resource "azurerm_application_insights" "app-insights" {

Expected Behaviour

Plan should be enerated

Actual Behaviour

Error 504

Steps to Reproduce

Just run terraform plan

Important Factoids

NA

References

NA

usr122 commented 2 weeks ago

We're seeing the same errors pretty consistently. The resource changes each time, but it's always on the resources' Application Insights. So far, just retrying the plan (multiple times in some cases) seems to eventually get it through, but that's getting untenable.

teowa commented 1 week ago

Hi @omkaracharya17 , thanks for submitting the issue!

The mentioned used provider version is 2.99.0 which releases year ago (not sure if you type the wrong version), and recent code change for azurerm_application_gateway was 3 months ago, no code change is made recently.

The 504 error might be something wrong at Azure side. And to help investigation, could you please help provide debug log which contain HTTP request trace?

pdefreitas commented 1 week ago

Same behavior on 3.95 sometimes the plan works, sometimes it gives a timeout. It seems to be Azure related.

JRobertEdwards commented 1 week ago

Also seeing this behaviour pretty consistently as outlined in this ticket https://github.com/hashicorp/terraform-provider-azurerm/issues/27267

Assume there's no resolution yet outside of brute forcing it over multiple tries

vivaladan commented 1 week ago

I also see this intermittently and have to re-run the plan. Usually one more try will do it.

corporate-gadfly commented 5 days ago

It might be helpful to remove the v/2.x (legacy) label, as this is happening with 3.x and 4.x versions as well.