Sort all variables, outputs, arguments and blocks in resource block.
Adjust code file's style. Add `numeric = false` for `random_string.name` in `201-mysql-fs-db` module as the name is used as `azurerm_mysql_flexible_server.default`'s `administrator_login` and the login name doesn't support a name start with number. Add minimum constraints for `random_password.password` in `201-mysql-fs-db` module as the password required a minimum complexity.
This commit is contained in:
@ -4,50 +4,54 @@ resource "random_pet" "rg_name" {
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = random_pet.rg_name.id
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
# Generate random value for the name
|
||||
resource "random_string" "name" {
|
||||
length = 8
|
||||
upper = false
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
# Generate random value for the login password
|
||||
resource "random_password" "password" {
|
||||
length = 8
|
||||
upper = true
|
||||
lower = true
|
||||
special = true
|
||||
numeric = false
|
||||
min_lower = 1
|
||||
min_numeric = 1
|
||||
min_special = 1
|
||||
min_upper = 1
|
||||
numeric = true
|
||||
override_special = "_"
|
||||
special = true
|
||||
upper = true
|
||||
}
|
||||
|
||||
# Manages the Virtual Network
|
||||
resource "azurerm_virtual_network" "default" {
|
||||
name = "vnet-${random_string.name.result}"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
address_space = ["10.0.0.0/16"]
|
||||
location = azurerm_resource_group.rg.location
|
||||
name = "vnet-${random_string.name.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
# Manages the Subnet
|
||||
resource "azurerm_subnet" "default" {
|
||||
address_prefixes = ["10.0.2.0/24"]
|
||||
name = "subnet-${random_string.name.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
virtual_network_name = azurerm_virtual_network.default.name
|
||||
address_prefixes = ["10.0.2.0/24"]
|
||||
service_endpoints = ["Microsoft.Storage"]
|
||||
|
||||
delegation {
|
||||
name = "fs"
|
||||
|
||||
service_delegation {
|
||||
name = "Microsoft.DBforMySQL/flexibleServers"
|
||||
|
||||
name = "Microsoft.DBforMySQL/flexibleServers"
|
||||
actions = [
|
||||
"Microsoft.Network/virtualNetworks/subnets/join/action",
|
||||
]
|
||||
@ -65,41 +69,38 @@ resource "azurerm_private_dns_zone" "default" {
|
||||
resource "azurerm_private_dns_zone_virtual_network_link" "default" {
|
||||
name = "mysqlfsVnetZone${random_string.name.result}.com"
|
||||
private_dns_zone_name = azurerm_private_dns_zone.default.name
|
||||
virtual_network_id = azurerm_virtual_network.default.id
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
virtual_network_id = azurerm_virtual_network.default.id
|
||||
}
|
||||
|
||||
# Manages the MySQL Flexible Server
|
||||
resource "azurerm_mysql_flexible_server" "default" {
|
||||
location = azurerm_resource_group.rg.location
|
||||
name = "mysqlfs-${random_string.name.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
administrator_login = random_string.name.result
|
||||
administrator_password = random_password.password.result
|
||||
zone = "1"
|
||||
version = "8.0.21"
|
||||
backup_retention_days = 7
|
||||
delegated_subnet_id = azurerm_subnet.default.id
|
||||
geo_redundant_backup_enabled = false
|
||||
|
||||
storage {
|
||||
size_gb = 20
|
||||
iops = 360
|
||||
}
|
||||
|
||||
delegated_subnet_id = azurerm_subnet.default.id
|
||||
private_dns_zone_id = azurerm_private_dns_zone.default.id
|
||||
sku_name = "GP_Standard_D2ds_v4"
|
||||
private_dns_zone_id = azurerm_private_dns_zone.default.id
|
||||
sku_name = "GP_Standard_D2ds_v4"
|
||||
version = "8.0.21"
|
||||
zone = "1"
|
||||
|
||||
high_availability {
|
||||
mode = "ZoneRedundant"
|
||||
standby_availability_zone = "2"
|
||||
}
|
||||
|
||||
maintenance_window {
|
||||
day_of_week = 0
|
||||
start_hour = 8
|
||||
start_minute = 0
|
||||
}
|
||||
storage {
|
||||
iops = 360
|
||||
size_gb = 20
|
||||
}
|
||||
|
||||
depends_on = [azurerm_private_dns_zone_virtual_network_link.default]
|
||||
}
|
||||
|
Reference in New Issue
Block a user