From 56b13218dc0c4a17cac4da44272c086f0b3c4674 Mon Sep 17 00:00:00 2001 From: cmendible <266546+cmendible@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:31:32 +0100 Subject: [PATCH] Refactor Bing resource deployment and update module outputs --- infra/main.tf | 3 +- infra/modules/cog/main.tf | 74 ++++++++++++++++++++++++++-------- infra/modules/cog/outputs.tf | 4 ++ infra/modules/cog/variables.tf | 1 - infra/variables.tf | 8 ---- 5 files changed, 63 insertions(+), 27 deletions(-) diff --git a/infra/main.tf b/infra/main.tf index 0eaba44..cf1c121 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -132,7 +132,6 @@ module "cog" { resource_group_name = azurerm_resource_group.rg.name resource_group_id = azurerm_resource_group.rg.id bing_name = local.bing_name - deploy_bing = var.deploy_bing cognitive_services_name = local.cognitive_services_name content_safety_name = local.content_safety_name speech_name = local.speech_name @@ -220,7 +219,7 @@ module "ca_aihub" { speech_key = module.cog.speech_key storage_connection_string = module.st.connection_string - bing_key = var.bing_key + bing_key = module.cog.bing_key tenant_id = data.azurerm_subscription.current.tenant_id managed_identity_client_id = module.mi.client_id diff --git a/infra/modules/cog/main.tf b/infra/modules/cog/main.tf index e4bc4ad..55874a6 100644 --- a/infra/modules/cog/main.tf +++ b/infra/modules/cog/main.tf @@ -31,24 +31,66 @@ resource "azurerm_cognitive_account" "speech" { custom_subdomain_name = var.speech_name } -resource "azapi_resource" "bing" { - count = var.deploy_bing ? 1 : 0 - name = var.bing_name - location = "global" - parent_id = var.resource_group_id - type = "Microsoft.Bing/accounts@2020-06-10" - schema_validation_enabled = false // Required for this service otherwise it will fail. - - body = jsonencode({ - kind = "Bing.Search.v7" - sku = { - name = "S1" - } - properties : { - statisticsEnabled = true +resource "azurerm_resource_group_template_deployment" "main" { + name = var.bing_name + resource_group_name = var.resource_group_name + deployment_mode = "Incremental" + parameters_content = jsonencode({ + "name" = { + value = var.bing_name + }, + "location" = { + value = "Global" + }, + "sku" = { + value = S1 + }, + "kind" = { + value = "Bing.Search.v7" } }) - response_export_values = ["properties.endpoint"] + template_content = <