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

Support additional configurations for azurerm_api_management_diagnostic and azurerm_api_management_api_diagnostic #9196

Open allenhumphreys opened 3 years ago

allenhumphreys commented 3 years ago

Community Note

Description

Both of these resources support many more configuration values. It'd be great if they were updated to allow configuring them using HCL instead of an ARM template deployment.

New or Affected Resource(s)

Potential Terraform Configuration

// https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-12-01/service/apis/diagnostics
resource "azurerm_api_management_api_diagnostic" "example" {
  resource_group_name      = azurerm_resource_group.example.name
  api_management_name      = azurerm_api_management.example.name
  api_name                 = azurerm_api_management_api.example.name
  api_management_logger_id = azurerm_api_management_logger.example.id

  identifier = "applicationinsights" // Identifier is not correctly marked as required currently, but should be

  always_log = "allErrors" // Only one possible value
  // Optional sampling block, defaults to 100. Could be simple input instead of block
  sampling {
    percentage = 5
  }

  // Optional frontend logging block
  frontend {
    request {
      headers_to_log = ["User-Agent"]
      bytes_to_log = 8129
    }
    response {
      headers_to_log = ["Date"]
      bytes_to_log = 8129
    }
  }
  // Optional backend logging block
  backend {
    request {
      headers_to_log = ["Request-Id"]
      bytes_to_log = 8129
    }
    response {
      headers_to_log = ["Date"]
      bytes_to_log = 8129
    }
  }
  log_client_ip = true
  http_correlation_prrotocol = "W3C" // None, Legacy, W3C
  verbosity = "error" // verbose, information, error
}

// https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-12-01/service/diagnostics
resource "azurerm_api_management_diagnostic" "example" {
  identifier               = "applicationinsights"
  resource_group_name      = azurerm_resource_group.example.name
  api_management_name      = azurerm_api_management.example.name
  api_management_logger_id = azurerm_api_management_logger.example.id

  always_log = "allErrors" // Only one possible value
  // Optional sampling block, defaults to 100. Could be simple input instead of block
  sampling {
    percentage = 5
  }

  // Optional frontend logging block
  frontend {
    request {
      headers_to_log = ["User-Agent"]
      bytes_to_log = 8129
    }
    response {
      headers_to_log = ["Date"]
      bytes_to_log = 8129
    }
  }
  // Optional backend logging block
  backend {
    request {
      headers_to_log = ["Request-Id"]
      bytes_to_log = 8129
    }
    response {
      headers_to_log = ["Date"]
      bytes_to_log = 8129
    }
  }
  log_client_ip = true
  http_correlation_prrotocol = "W3C" // None, Legacy, W3C
  verbosity = "error" // verbose, information, error
}

References

allenhumphreys commented 3 years ago

Seems to duplicate #9169, will verify with latest provider version

salvisbh commented 3 years ago

9169 does not appear to be a duplicate, since it only allows definition at the Api level. This issue, on the other hand, addresses configuring at the API management level, for example to globally enable the W3C correlation protocol, see https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-12-01/service/diagnostics.

slynickel commented 3 years ago

I've proposed a PR for adding the options to azurerm_api_management_diagnostic in #10325. I'm new to this repository so I'm not sure if I need to do anything additional to get it reviewed. I found #10322 as part of testing that PR that affects the currently released azurerm_api_management_api_diagnostic resource as well.

slynickel commented 3 years ago

This can be closed by #10325