Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
# ------------------------------------------------------------------------------------------------------
Expand All @@ -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
# ------------------------------------------------------------------------------------------------------
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down