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" {
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

View File

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

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