Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

101-app-service-environment #391

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions quickstart/101-app-service-environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Azure App Service Environment v3
This template deploys an Azure App Service Environment v3.

## Terraform resource types

- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network)
- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet)
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
- [azurerm_app_service_environment_v3](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_environment_v3)

## Variables

| Name | Description | Default value |
|-|-|-|
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
| `resource_group_location` | Location of the resource group. | eastus |
| `virtual_network_name` | Name of the virtual network resource. | "" |
| `subnet_name` | Name of the virtual network subnet. | "" |
| `app_service_environment_v3_name` | Name of the App Service Environment v3 resource. | "" |

## Example
83 changes: 83 additions & 0 deletions quickstart/101-app-service-environment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}

resource "azurerm_resource_group" "rg" {
location = var.resource_group_location
name = random_pet.rg_name.id
}

resource "random_string" "azurerm_virtual_network_name" {
length = 13
lower = true
numeric = false
special = false
upper = false
}

resource "azurerm_virtual_network" "example" {
name = coalesce(var.virtual_network_name, "vnet-${random_string.azurerm_virtual_network_name.result}")
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
address_space = ["10.0.0.0/16"]
}

resource "random_string" "azurerm_subnet_name" {
length = 13
lower = true
numeric = false
special = false
upper = false
}

resource "azurerm_subnet" "ase" {
name = coalesce(var.subnet_name, "subnet-${random_string.azurerm_subnet_name.result}")
resource_group_name = azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.1.0/24"]

delegation {
name = "delegation"

service_delegation {
name = "Microsoft.Web/hostingEnvironments"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}

resource "random_string" "azurerm_app_service_environment_v3_name" {
length = 13
lower = true
numeric = false
special = false
upper = false
}

resource "azurerm_app_service_environment_v3" "example" {
name = coalesce(var.app_service_environment_v3_name, "asev3-${random_string.azurerm_app_service_environment_v3_name.result}")
resource_group_name = azurerm_resource_group.rg.name
subnet_id = azurerm_subnet.ase.id

internal_load_balancing_mode = "Web, Publishing"

cluster_setting {
name = "DisableTls1.0"
value = "1"
}

cluster_setting {
name = "InternalEncryption"
value = "true"
}

cluster_setting {
name = "FrontEndSSLCipherSuiteOrder"
value = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
}

tags = {
env = "production"
terraformed = "true"
}
}
15 changes: 15 additions & 0 deletions quickstart/101-app-service-environment/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}

output "virtual_network_name" {
value = azurerm_virtual_network.example.name
}

output "subnet_name" {
value = azurerm_subnet.ase.name
}

output "app_service_environment_v3_name" {
value = azurerm_app_service_environment_v3.example.name
}
18 changes: 18 additions & 0 deletions quickstart/101-app-service-environment/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_version = ">=1.0"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}

provider "azurerm" {
features {}
}
29 changes: 29 additions & 0 deletions quickstart/101-app-service-environment/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}

variable "resource_group_location" {
type = string
default = "eastus"
description = "Location of the resource group."
}

variable "virtual_network_name" {
type = string
description = "The name of the virtual network resource. The value will be randomly generated if blank."
default = ""
}

variable "subnet_name" {
type = string
description = "The name of the virtual network subnet. The value will be randomly generated if blank."
default = ""
}

variable "app_service_environment_v3_name" {
type = string
description = "The name of the App Service Environment v3 resource. The value will be randomly generated if blank."
default = ""
}
Loading