Search code examples
azureterraformterraform-provider-azureazure-waf

How to set Azure Web Application Firewall (WAF) logs via Terraforn?


I am trying to do this, via Terraform code: enter image description here

However, I can not find how. Is it some obscure resource or it is not implemented at all ?


Solution

  • You can use the azurerm_monitor_diagnostic_setting to configure the setting as ydaetskcoR said, it works like the screenshot you provided shows. Here is the example code:

    resource "azurerm_monitor_diagnostic_setting" "example" {
      name               = "example"
      target_resource_id = "application_gateway_resource_id"
      storage_account_id = data.azurerm_storage_account.example.id
    
      log {
        category = "ApplicationGatewayFirewallLog"
        enabled  = true
    
        retention_policy {
          enabled = true
          days = 30
        }
      }
    
    }
    

    Terraform does not support Data for application gateway, so you need to input the resource id of the existing application gateway yourself, or quote the id when you create the new application gateway.