diff --git a/quickstart/101-web-app-linux-java/app_service.tf b/quickstart/101-web-app-linux-java/app_service.tf index 6de12e73..0545856e 100644 --- a/quickstart/101-web-app-linux-java/app_service.tf +++ b/quickstart/101-web-app-linux-java/app_service.tf @@ -1,24 +1,24 @@ resource "azurerm_app_service_plan" "default" { - name = "${var.name}-plan" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" + name = "${random_pet.prefix.id}-plan" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name kind = "Linux" # Reserved must be set to true for Linux App Service Plans reserved = true sku { - tier = "${var.plan_tier}" - size = "${var.plan_sku}" + tier = var.plan_tier + size = var.plan_sku } } -resource "azurerm_app_service" "default" { - name = "${var.dns_prefix}-${var.name}-${var.environment}-app" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" - app_service_plan_id = "${azurerm_app_service_plan.default.id}" +resource "azurerm_app_service" "main" { + name = "${var.dns_prefix}-${random_pet.prefix.id}-${var.environment}-app" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name + app_service_plan_id = azurerm_app_service_plan.default.id site_config { always_on = true diff --git a/quickstart/101-web-app-linux-java/main.tf b/quickstart/101-web-app-linux-java/main.tf index f029cc2f..dff25ab9 100644 --- a/quickstart/101-web-app-linux-java/main.tf +++ b/quickstart/101-web-app-linux-java/main.tf @@ -1,8 +1,9 @@ -provider "azurerm" { - version = "=1.36.0" +resource "azurerm_resource_group" "default" { + name = "${random_pet.prefix.id}-${var.environment}-rg" + location = var.location } -resource "azurerm_resource_group" "default" { - name = "${var.name}-${var.environment}-rg" - location = "${var.location}" -} +resource "random_pet" "prefix" { + prefix = var.prefix + length = 2 +} \ No newline at end of file diff --git a/quickstart/101-web-app-linux-java/providers.tf b/quickstart/101-web-app-linux-java/providers.tf new file mode 100644 index 00000000..dc42605e --- /dev/null +++ b/quickstart/101-web-app-linux-java/providers.tf @@ -0,0 +1,18 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">= 3.0, < 4.0" + } + random = { + source = "hashicorp/random" + version = ">= 3.0" + } + } +} + +provider "azurerm" { + features {} +} \ No newline at end of file diff --git a/quickstart/101-web-app-linux-java/variables.tf b/quickstart/101-web-app-linux-java/variables.tf index ebdaa2cc..5f8c24cc 100644 --- a/quickstart/101-web-app-linux-java/variables.tf +++ b/quickstart/101-web-app-linux-java/variables.tf @@ -1,35 +1,35 @@ -variable "name" { - type = "string" - description = "Location of the azure resource group." - default = "demo-tfquickstart" +variable "prefix" { + type = string + default = "web-app-linux-java" + description = "Prefix of the resource name" } variable "environment" { - type = "string" + type = string description = "Name of the deployment environment" default = "dev" } variable "location" { - type = "string" + type = string description = "Location to deploy the resource group" - default = "West US 2" + default = "eastus" } variable "dns_prefix" { - type = "string" + type = string description = "A prefix for any dns based resources" default = "tfq" } variable "plan_tier" { - type = "string" + type = string description = "The tier of app service plan to create" default = "Standard" } variable "plan_sku" { - type = "string" + type = string description = "The sku of app service plan to create" default = "S1" }