diff --git a/quickstart/201-function-app/main.tf b/quickstart/201-function-app/main.tf index 5b4f05da..5c09c636 100644 --- a/quickstart/201-function-app/main.tf +++ b/quickstart/201-function-app/main.tf @@ -1,10 +1,10 @@ resource "azurerm_resource_group" "default" { - name = "${var.name_prefix}-rg" + name = "${random_pet.prefix.id}-rg" location = var.location } resource "azurerm_storage_account" "default" { - name = "${var.name_prefix}sa" + name = "${replace(random_pet.prefix.id, "-", "")}sa" resource_group_name = azurerm_resource_group.default.name location = azurerm_resource_group.default.location account_tier = "Standard" @@ -14,7 +14,7 @@ resource "azurerm_storage_account" "default" { } resource "azurerm_service_plan" "default" { - name = "${var.name_prefix}-sap" + name = "${random_pet.prefix.id}-sap" location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name sku_name = "Y1" @@ -27,8 +27,8 @@ resource "azurerm_service_plan" "default" { # If you would like to set the required number of failed requests for an instance to be deemed unhealthy and removed from the load balancer under health check feature, using health_check_eviction_time_in_min property under site_config block. Terraform will set the key WEBSITE_HEALTHCHECK_MAXPINGFAILURES # in app_setting for you. -resource "azurerm_linux_function_app" "test" { - name = "${var.name_prefix}-lfa" +resource "azurerm_linux_function_app" "main" { + name = "${random_pet.prefix.id}-lfa" location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name service_plan_id = azurerm_service_plan.default.id @@ -45,3 +45,7 @@ resource "azurerm_linux_function_app" "test" { } } +resource "random_pet" "prefix" { + prefix = var.prefix + length = 2 +} \ No newline at end of file diff --git a/quickstart/201-function-app/outputs.tf b/quickstart/201-function-app/outputs.tf new file mode 100644 index 00000000..9a927e05 --- /dev/null +++ b/quickstart/201-function-app/outputs.tf @@ -0,0 +1,11 @@ +output "resource_group_name" { + value = azurerm_resource_group.default.name +} + +output "storage_account_name" { + value = azurerm_storage_account.default.name +} + +output "linux_function_app_name" { + value = azurerm_linux_function_app.main.name +} \ No newline at end of file diff --git a/quickstart/201-function-app/providers.tf b/quickstart/201-function-app/providers.tf index 74d8804c..8751185a 100644 --- a/quickstart/201-function-app/providers.tf +++ b/quickstart/201-function-app/providers.tf @@ -1,10 +1,14 @@ terraform { - required_version = ">=1.0" + required_version = ">= 1.0" required_providers { azurerm = { source = "hashicorp/azurerm" - version = "~>3.8" + version = ">= 3.0, < 4.0" + } + random = { + source = "hashicorp/random" + version = ">= 3.0" } } } diff --git a/quickstart/201-function-app/variables.tf b/quickstart/201-function-app/variables.tf index e4c01012..5c6b4ed4 100644 --- a/quickstart/201-function-app/variables.tf +++ b/quickstart/201-function-app/variables.tf @@ -1,10 +1,11 @@ -variable "name_prefix" { +variable "prefix" { type = string + default = "function-app" description = "Prefix of the resource name" } variable "location" { type = string description = "Location to deploy the resource group" - default = "West US 2" + default = "eastus" }