azureterraformauth0

How to create Auth0 Log Stream with terraform


I am trying to create Log Stream for Auth0 to push logs to azure. There is a resource for it - https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/log_stream

But when I try to specify the resource as

resource "auth0_log_stream" "example" {
  name   = "Azure logs"
  type   = "eventbridge"
  status = "active"

  sink {
    azure_region          = "westeurope"
    azure_resource_group  = "my_resource_group"
    azure_subscription_id = "my-subscription-id"
  }
}

It plans successfully with

  + resource "auth0_log_stream" "example" {
      + id          = (known after apply)
      + is_priority = false
      + name        = "Azure logs"
      + status      = "active"
      + type        = "eventbridge"

      + sink {
          + aws_partner_event_source = (known after apply)
          + azure_partner_topic      = (known after apply)
          + azure_region             = "westeurope"
          + azure_resource_group     = "my_resource_group"
          + azure_subscription_id    = "my-subscription-id"
          + http_content_format      = (known after apply)
        }
    }

And then fails with

400 Bad Request: Payload validation error: 'Data does not match any schemas from 'oneOf''.

How to properly use it for azure only?


Solution

  • Create Auth0 Log Stream for azure with terraform

    As per the error description, the type mentioned in the `resource "auth0_log_stream"` is referring to "eventbridge" which in general refer AWS specific value.

    When you are trying to create Log Stream for Auth0 to push logs to azure then we need to select the Azure specific value i.e., "eventgrid".

    As per the documentation to push the logs we need to specify the type as per the cloud environment.

    Demo configuration:

    resource "auth0_log_stream" "example_azure" {
      name   = "Azure Event Grid Log Stream"
      type   = "eventgrid"
      status = "active"
    
      sink {
        azure_region          = "your_azure_region"          
        azure_resource_group  = "your_resource_group_name"   
        azure_subscription_id = "your_subscription_id"      
      }
    }
    

    Refer:

    https://github.com/auth0/terraform-provider-auth0/issues/886