Quickstart for WebApp with MySQL backend
This commit is contained in:
parent
a964345544
commit
1a74307d5d
5
quickstart/WebAppMySql/main.tf
Normal file
5
quickstart/WebAppMySql/main.tf
Normal file
@ -0,0 +1,5 @@
|
||||
resource "azurerm_resource_group" "webAppMySqlRg" {
|
||||
name = "${var.rg}"
|
||||
location = "${var.loc}"
|
||||
tags = "${var.tags}"
|
||||
}
|
29
quickstart/WebAppMySql/mysql.tf
Normal file
29
quickstart/WebAppMySql/mysql.tf
Normal file
@ -0,0 +1,29 @@
|
||||
resource "azurerm_mysql_server" "webAppBackend" {
|
||||
name = "${var.siteName}pgserver"
|
||||
location = "${azurerm_resource_group.webAppMySqlRg.location}"
|
||||
resource_group_name = "${azurerm_resource_group.webAppMySqlRg.name}"
|
||||
tags = "${azurerm_resource_group.webAppMySqlRg.tags}"
|
||||
|
||||
administrator_login = "${var.administratorLogin}"
|
||||
administrator_login_password = "${var.administratorLoginPassword}"
|
||||
version = "${var.mysqlVersion}"
|
||||
ssl_enforcement = "Disabled"
|
||||
sku {
|
||||
name = "${var.databaseSkuName}"
|
||||
capacity = "${var.databaseDTU}"
|
||||
tier = "${var.databaseSkuTier}"
|
||||
family = "${var.databaseSkuFamily}"
|
||||
}
|
||||
storage_profile {
|
||||
storage_mb = "${var.databaseSkuSizeMB}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_mysql_database" "webAppBackend" {
|
||||
name = "${var.siteName}database"
|
||||
resource_group_name = "${azurerm_resource_group.webAppMySqlRg.name}"
|
||||
|
||||
server_name = "${azurerm_mysql_server.webAppBackend.name}"
|
||||
charset = "utf8"
|
||||
collation = "utf8_unicode_ci"
|
||||
}
|
15
quickstart/WebAppMySql/output.tf
Normal file
15
quickstart/WebAppMySql/output.tf
Normal file
@ -0,0 +1,15 @@
|
||||
output "webAppUrl" {
|
||||
value = "${azurerm_app_service.webAppFrontend.default_site_hostname}"
|
||||
}
|
||||
|
||||
output "databaseName" {
|
||||
value = "${azurerm_mysql_database.webAppBackend.name}"
|
||||
}
|
||||
|
||||
output "databaseServerName" {
|
||||
value = "${azurerm_mysql_server.webAppBackend.fqdn}"
|
||||
}
|
||||
|
||||
output "appServicePlanName" {
|
||||
value = "${azurerm_app_service_plan.webAppFrontend.name}"
|
||||
}
|
3
quickstart/WebAppMySql/providers.tf
Normal file
3
quickstart/WebAppMySql/providers.tf
Normal file
@ -0,0 +1,3 @@
|
||||
provider "azurerm" {
|
||||
version = "~>1.17"
|
||||
}
|
12
quickstart/WebAppMySql/terraform.tfvars
Normal file
12
quickstart/WebAppMySql/terraform.tfvars
Normal file
@ -0,0 +1,12 @@
|
||||
rg = "mcg623webAppMysql"
|
||||
loc = "eastus2"
|
||||
tags = {
|
||||
type = "sample"
|
||||
services = "MySql, WebApp, Azure database"
|
||||
}
|
||||
|
||||
administratorLogin = "markg"
|
||||
siteName = "mcgecd69mysql"
|
||||
|
||||
servicePlanTier = "Standard"
|
||||
servicePlanSize = "S1"
|
65
quickstart/WebAppMySql/variables.tf
Normal file
65
quickstart/WebAppMySql/variables.tf
Normal file
@ -0,0 +1,65 @@
|
||||
variable "rg" {
|
||||
description = "Azure resource group for all resources."
|
||||
}
|
||||
|
||||
variable "siteName" {
|
||||
description = "Name of azure web app"
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "Azure Tags for all resources."
|
||||
default = {}
|
||||
}
|
||||
|
||||
|
||||
variable "administratorLogin" {
|
||||
description = "Database administrator login name"
|
||||
}
|
||||
|
||||
variable "administratorLoginPassword" {
|
||||
description = "Database administrator password"
|
||||
}
|
||||
|
||||
variable "databaseDTU" {
|
||||
description = "Azure database for MySQL pricing tier"
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "databaseSkuName" {
|
||||
description = "Azure database for MySQL sku name"
|
||||
default = "GP_Gen4_2"
|
||||
}
|
||||
|
||||
variable "databaseSkuFamily" {
|
||||
description = "Azure database for MySQL sku family"
|
||||
default = "Gen4"
|
||||
}
|
||||
|
||||
|
||||
variable "databaseSkuSizeMB" {
|
||||
description = "Azure database for MySQL Sku Size"
|
||||
default = 5120
|
||||
}
|
||||
|
||||
variable "databaseSkuTier" {
|
||||
description = "Azure database for MySQL pricing tier"
|
||||
default = "GeneralPurpose"
|
||||
}
|
||||
|
||||
variable "mysqlVersion" {
|
||||
description = "MySQL version"
|
||||
default = "5.6"
|
||||
}
|
||||
|
||||
variable "loc" {
|
||||
description = "Location for all resources."
|
||||
default = "eastus2"
|
||||
}
|
||||
|
||||
variable "servicePlanTier" {
|
||||
description = "Azure managed application service plan pricing tier"
|
||||
}
|
||||
|
||||
variable "servicePlanSize" {
|
||||
description = "Azure managed application service plan instance size"
|
||||
}
|
25
quickstart/WebAppMySql/webapp.tf
Normal file
25
quickstart/WebAppMySql/webapp.tf
Normal file
@ -0,0 +1,25 @@
|
||||
resource "azurerm_app_service_plan" "webAppFrontend" {
|
||||
name = "${var.siteName}serviceplan"
|
||||
resource_group_name = "${azurerm_resource_group.webAppMySqlRg.name}"
|
||||
location = "${azurerm_resource_group.webAppMySqlRg.location}"
|
||||
tags = "${azurerm_resource_group.webAppMySqlRg.tags}"
|
||||
|
||||
sku {
|
||||
tier = "${var.servicePlanTier}"
|
||||
size = "${var.servicePlanSize}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_app_service" "webAppFrontend" {
|
||||
name = "${var.siteName}"
|
||||
location = "${azurerm_resource_group.webAppMySqlRg.location}"
|
||||
resource_group_name = "${azurerm_resource_group.webAppMySqlRg.name}"
|
||||
tags = "${azurerm_resource_group.webAppMySqlRg.tags}"
|
||||
|
||||
app_service_plan_id = "${azurerm_app_service_plan.webAppFrontend.id}"
|
||||
connection_string {
|
||||
name = "DefaultConnect"
|
||||
type = "MySql"
|
||||
value = "Database=${azurerm_mysql_database.webAppBackend.name};Data Source=${azurerm_mysql_server.webAppBackend.fqdn};User Id=${var.administratorLogin}@${azurerm_mysql_server.webAppBackend.name};Password=${var.administratorLoginPassword}"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user