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.61k stars 4.65k forks source link

Add folder to azurerm_application_insights_analytics_item #14349

Open maxhillaert opened 2 years ago

maxhillaert commented 2 years ago

Community Note

Description

The azurerm_application_insights_analytics_item does not seem to support assigning a folder to query. It looks like an item can be a "folder" , but how to assign a "query" to a "folder"? I'd say this is missing or the documentation should explain how to do it

New or Affected Resource(s)

Potential Terraform Configuration

resource "azurerm_application_insights_analytics_item" "example" {
  name                    = "testquery"
  application_insights_id = azurerm_application_insights.example.id
  content                 = "requests //simple example query"
  scope                   = "shared"
  type                    = "query"
  folderPath           = "folderA"  // or something?
}

References

sinbai commented 2 years ago

Per the doc, the "folder" is a type of analytics Item. Currently, when trying to create an analytics item of type "folder" in terraform, the API returns an error. Details:

Terraform Configuration:

resource "azurerm_application_insights_analytics_item" "example" {
  name                    = "testquery"
  application_insights_id = azurerm_application_insights.example.id
  content                 = "requests //simple example query"
  scope                   = "shared"
  type                    = "folder"
}

After running Terraform apply command, the API returns "Unsupported type parameter" error :

 checking for presence of existing Application Insights Analytics Items insights.AnalyticsItemsClient#List: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Unsupported type parameter" InnerError={"diagnosticcontext":"64aa66f6-4718-45a5-8dd8-f55e15c75f41","time":"2021-12-28T06:12:00.7532414Z"}

After confirming with the API team, there is no "folder" type in their code. And in the file history, it is not found that this type has ever been supported. Maybe there is a inconsistency between the code and the documentation. This API issue has been submitted. Terraform would fix this after the API issue is solved.