fix 101-web-app-linux-java example (#174)

This commit is contained in:
Dingjia Chen 2023-02-24 01:24:23 -06:00 committed by GitHub
parent 4ada2e44f0
commit a543607bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 26 deletions

View File

@ -1,24 +1,24 @@
resource "azurerm_app_service_plan" "default" { resource "azurerm_app_service_plan" "default" {
name = "${var.name}-plan" name = "${random_pet.prefix.id}-plan"
location = "${azurerm_resource_group.default.location}" location = azurerm_resource_group.default.location
resource_group_name = "${azurerm_resource_group.default.name}" resource_group_name = azurerm_resource_group.default.name
kind = "Linux" kind = "Linux"
# Reserved must be set to true for Linux App Service Plans # Reserved must be set to true for Linux App Service Plans
reserved = true reserved = true
sku { sku {
tier = "${var.plan_tier}" tier = var.plan_tier
size = "${var.plan_sku}" size = var.plan_sku
} }
} }
resource "azurerm_app_service" "default" { resource "azurerm_app_service" "main" {
name = "${var.dns_prefix}-${var.name}-${var.environment}-app" name = "${var.dns_prefix}-${random_pet.prefix.id}-${var.environment}-app"
location = "${azurerm_resource_group.default.location}" location = azurerm_resource_group.default.location
resource_group_name = "${azurerm_resource_group.default.name}" resource_group_name = azurerm_resource_group.default.name
app_service_plan_id = "${azurerm_app_service_plan.default.id}" app_service_plan_id = azurerm_app_service_plan.default.id
site_config { site_config {
always_on = true always_on = true

View File

@ -1,8 +1,9 @@
provider "azurerm" { resource "azurerm_resource_group" "default" {
version = "=1.36.0" name = "${random_pet.prefix.id}-${var.environment}-rg"
location = var.location
} }
resource "azurerm_resource_group" "default" { resource "random_pet" "prefix" {
name = "${var.name}-${var.environment}-rg" prefix = var.prefix
location = "${var.location}" length = 2
} }

View File

@ -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 {}
}

View File

@ -1,35 +1,35 @@
variable "name" { variable "prefix" {
type = "string" type = string
description = "Location of the azure resource group." default = "web-app-linux-java"
default = "demo-tfquickstart" description = "Prefix of the resource name"
} }
variable "environment" { variable "environment" {
type = "string" type = string
description = "Name of the deployment environment" description = "Name of the deployment environment"
default = "dev" default = "dev"
} }
variable "location" { variable "location" {
type = "string" type = string
description = "Location to deploy the resource group" description = "Location to deploy the resource group"
default = "West US 2" default = "eastus"
} }
variable "dns_prefix" { variable "dns_prefix" {
type = "string" type = string
description = "A prefix for any dns based resources" description = "A prefix for any dns based resources"
default = "tfq" default = "tfq"
} }
variable "plan_tier" { variable "plan_tier" {
type = "string" type = string
description = "The tier of app service plan to create" description = "The tier of app service plan to create"
default = "Standard" default = "Standard"
} }
variable "plan_sku" { variable "plan_sku" {
type = "string" type = string
description = "The sku of app service plan to create" description = "The sku of app service plan to create"
default = "S1" default = "S1"
} }