Azure / terraform-azurerm-avm-res-cognitiveservices-account

This Terraform module is designed to manage Azure Cognitive Services. It provides a comprehensive set of variables and resources to configure and deploy Cognitive Services in Azure.
https://github.com/Azure/terraform-azurerm-avm-res-cognitiveservices-account
MIT License
6 stars 10 forks source link

[AVM Module Issue]: logAnalyticsDestinationType is not set correctly for Diagnostic settings #55

Closed acauret closed 1 month ago

acauret commented 3 months ago

Check for previous/existing GitHub issues

Issue Type?

Bug

(Optional) Module Version

No response

(Optional) Correlation Id

No response

Description

The logAnalyticsDestinationType should not be Dedicated but allow seeting of null value image

as everytime terrform runs it thinks there is a change. image

lonegunmanb commented 1 month ago

Thanks for opening this pr to us @acauret and sorry for the late reply, this diagnostic setting is required by Azure Verified Module Specification so we won't fix it.

tonyskidmore commented 2 weeks ago

@lonegunmanb does this need more of a review? The code below will always want to make changes on each run, which is certainly not ideal. Setting the azurerm_monitor_diagnostic_setting outside of the module is the useable workaround.


terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "random_string" "example" {
  length  = 5
  special = false
  upper   = false
  lower   = true
}

resource "azurerm_resource_group" "rg" {
  name     = "rg-openai-avm"
  location = "uksouth"
}

resource "azurerm_log_analytics_workspace" "law" {
  name                = "law-testing-${random_string.example.result}"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  sku                 = "PerGB2018"
  retention_in_days   = 30
}

module "openai" {
  source  = "Azure/avm-res-cognitiveservices-account/azurerm"
  version = "0.3.0"

  kind                = "OpenAI"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location

  name                          = "oai-testing-${random_string.example.result}"
  sku_name                      = "S0"
  public_network_access_enabled = true

  diagnostic_settings = {
    sendToLogAnalytics = {
      name = "sendToLogAnalytics"
      workspace_resource_id = azurerm_log_analytics_workspace.law.id
    }
  }

  cognitive_deployments = {
    "gpt-35-turbo" = {
      name = "gpt-35-turbo"
      model = {
        format  = "OpenAI"
        name    = "gpt-35-turbo"
        version = "0301"
      }
      scale = {
        type = "Standard"
      }
    }
  }
}