diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf index 362b9998b93..763f5ebc99e 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf @@ -2,7 +2,7 @@ # Deploy app service plan # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "plan_name" { - name = random_string.resource_token.result + name = local.resource_token resource_type = "azurerm_app_service_plan" random_length = 0 clean_input = true @@ -22,7 +22,7 @@ resource "azurerm_service_plan" "plan" { # Deploy app service web app # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "web_name" { - name = "web-${random_string.resource_token.result}" + name = "web-${local.resource_token}" resource_type = "azurerm_app_service" random_length = 0 clean_input = true @@ -69,7 +69,7 @@ resource "azurerm_linux_web_app" "web" { # Deploy app service api # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "appi_name" { - name = "api-${random_string.resource_token.result}" + name = "api-${local.resource_token}" resource_type = "azurerm_app_service" random_length = 0 clean_input = true diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf index d94f6f48f25..618a080e9c4 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf @@ -2,7 +2,7 @@ # Deploy cosmos db account # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "db_acc_name" { - name = random_string.resource_token.result + name = local.resource_token resource_type = "azurerm_cosmosdb_account" random_length = 0 clean_input = true diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf index 1cea32beedc..5298b48438e 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf @@ -2,7 +2,7 @@ # DEPLOY AZURE KEYVAULT # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "kv_name" { - name = random_string.resource_token.result + name = local.resource_token resource_type = "azurerm_key_vault" random_length = 0 clean_input = true diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf index dedb1f01410..6e626fdcefd 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf @@ -2,7 +2,7 @@ # Deploy log analytics workspace # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "workspace_name" { - name = random_string.resource_token.result + name = local.resource_token resource_type = "azurerm_log_analytics_workspace" random_length = 0 clean_input = true diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index e52cf248ba6..d9c3a0c735c 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -1,5 +1,7 @@ locals { tags = { azd-env-name : var.environment_name } + sha = base64encode(sha256("${var.environment_name}${var.location}${data.azurerm_client_config.current.subscription_id}")) + resource_token = substr(replace(lower(local.sha), "[^A-Za-z0-9_]", ""), 0, 13) api_command_line = "gunicorn --workers 4 --threads 2 --timeout 60 --access-logfile \"-\" --error-logfile \"-\" --bind=0.0.0.0:8000 -k uvicorn.workers.UvicornWorker todo.app:app" } # ------------------------------------------------------------------------------------------------------ @@ -19,14 +21,6 @@ resource "azurerm_resource_group" "rg" { tags = local.tags } -resource "random_string" "resource_token" { - length = 10 - upper = false - lower = true - numeric = false - special = false -} - # ------------------------------------------------------------------------------------------------------ # Deploy application insights # ------------------------------------------------------------------------------------------------------ @@ -37,5 +31,5 @@ module "applicationinsights" { environment_name = var.environment_name workspace_id = azurerm_log_analytics_workspace.workspace.id tags = azurerm_resource_group.rg.tags - resource_token = random_string.resource_token.result + resource_token = local.resource_token } diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/provider.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/provider.tf index cd31bba2c39..b155125c556 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/provider.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/provider.tf @@ -2,7 +2,7 @@ # Configure the Azure Provider terraform { - required_version = "= v1.1.7" + required_version = "~> v1.1.7" required_providers { azurerm = { version = "~>3.18.0"