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

azurerm_application_insights_workbook does not allow programmatically creating workbooks with `"category": "workItems"` #27740

Open hansmbakker opened 1 month ago

hansmbakker commented 1 month ago

Is there an existing issue for this?

Community Note

Terraform Version

-

AzureRM Provider Version

4.6.0

Affected Resource(s)/Data Source(s)

application_insights_workbook

Terraform Configuration Files

-

Debug Output/Panic Output

-

Expected Behaviour

It is possible to create "workItems" workbooks for Application Insights

Actual Behaviour

The documentation lists only workbook and sentinel as possible options for the category parameter.

Steps to Reproduce

No response

Important Factoids

No response

References

This is related to the Application Insights work item integration .

It creates a workbook resource with category = workItems, but it is not possible to do this using the application_insights_workbook terraform resource.

teowa commented 1 month ago

Hi @hansmbakker , as I tested we can successfully provision the azurerm_application_insights_workbook with category="workItems" with AzureRM v4.6.0. The provider only validate the value as a non-empty string before send it to Azure API, as in the doc, There may be additional category types beyond the following: workbook, sentinel.

hansmbakker commented 1 month ago

I tried it, I agree, it is a documentation issue. Can you please route it to the correct place?

The following code works for me:

# Create a workbook for creating work items in Azure DevOps
# This is the IaC version of https://learn.microsoft.com/en-us/azure/azure-monitor/app/release-and-work-item-insights?tabs=work-item-integration#create-and-configure-a-work-item-template
resource "azurerm_application_insights_workbook" "new-workitem-workbook" {
  # name is required to be a guid
  name                = random_uuid.new-workitem-workbook.result
  resource_group_name = azurerm_resource_group.monitoring.name
  location            = azurerm_resource_group.monitoring.location
  display_name        = "Application Insights work item template"

  # BUG: https://github.com/hashicorp/terraform-provider-azurerm/issues/27755
  # lower(...) is required until the bug is fixed
  source_id = lower(azurerm_application_insights.monitoring.id)

  category = "workItems"

  data_json = templatefile("monitoring-templates/new-workitem-workbook.json.tpl",
    {
      application_insights_id  = azurerm_application_insights.monitoring.id,
      azure_devops_project_url = var.azure_devops_project_url,
  })

  tags = {
    # hidden-xxx tags are copied as-is from generated workbook (including the typo in AzuzreDevOps). Not sure what they are used for.
    # "hidden-title" is not used because it throws a terraform error saying that display_name should be used instead
    "hidden-workitemworkbook" = "AzuzreDevOps"
  }
}