Skip to content

walrus-catalog/terraform-azure-mysql

Repository files navigation

Azure MySQL Flexible Server

Terrafom module to deploy a MySQL Flexible Server on Azure Cloud.

  • Support standalone(one read-write instance) and replication(one read-write instance and multiple read-only instances, for read write splitting).

Usage

module "mysql" {
  source = "..."

  infrastructure = {
    resource_group  = "..."
    virtual_network = "..."
    subnet          = "..."
    domain_suffix   = "..."
  }

  resources = {
    class = "B_Standard_B1s"
  }

  storage = {
    size = 20480
  }
}

Examples

Contributing

Please read our contributing guide if you're interested in contributing to Walrus template.

Requirements

Name Version
terraform >= 1.0
azurerm >= 3.88.0
random >= 3.5.1

Providers

Name Version
azurerm >= 3.88.0
random >= 3.5.1

Modules

No modules.

Resources

Name Type
azurerm_mysql_flexible_database.database resource
azurerm_mysql_flexible_server.primary resource
azurerm_mysql_flexible_server.secondary resource
azurerm_private_dns_zone.default resource
azurerm_private_dns_zone_virtual_network_link.default resource
azurerm_resource_group.default resource
azurerm_subnet.default resource
azurerm_virtual_network.default resource
random_password.password resource
random_string.name_suffix resource
azurerm_private_dns_zone.selected data source
azurerm_resource_group.selected data source
azurerm_subnet.selected data source
azurerm_virtual_network.selected data source

Inputs

Name Description Type Default Required
architecture Specify the deployment architecture, select from standalone or replication. string "standalone" no
context Receive contextual information. When Walrus deploys, Walrus will inject specific contextual information into this field.

Examples:
context:
project:
name: string
id: string
environment:
name: string
id: string
resource:
name: string
id: string
map(any) {} no
database Specify the database name. The database name must be 2-64 characters long and start with any lower letter, combined with number, or symbols: - _.
The database name cannot be MySQL forbidden keyword.
string "mydb" no
engine_version Specify the deployment engine version of the MySQL Flexible Server to use. Possible values are 5.7, and 8.0.21. string "8.0.21" no
infrastructure Specify the infrastructure information for deploying.

Examples:
infrastructure:
resource_group: string, optional # the resource group name where to deploy the MySQL Flexible Server
virtual_network: string, optional # the virtual network name where to deploy the MySQL Flexible Server
subnet: string, optional # the subnet name under the virtual network where to deploy the MySQL Flexible Server
domain_suffix: string, optional # a private DNS namespace of the PrivateZone where to register the applied MySQL service. It must end with 'mysql.database.azure.com'
object({
resource_group = optional(string)
virtual_network = optional(string)
subnet = optional(string)
domain_suffix = optional(string)
})
{} no
password Specify the account password. The password must be 8-128 characters long and start with any letter, number, or symbols: ! # $ % ^ & * ( ) _ + - =.
If not specified, it will generate a random password.
string null no
replication_readonly_replicas Specify the number of read-only replicas under the replication deployment. number 1 no
resources Specify the computing resources.
The computing resource design of Azure Cloud is very complex, it also needs to consider on the storage resource, please view the specification document for more information.
For example: B_Standard_B1s, GP_Standard_D2ads_v5 or BC_Standard_E2ds_v4
See https://learn.microsoft.com/en-us/azure/mysql/flexible-server/concepts-service-tiers-storage#service-tiers-size-and-server-types.
Examples:
resources:
class: string, optional # sku
object({
class = optional(string, "B_Standard_B1s")
})
{
"class": "B_Standard_B1s"
}
no
storage Choosing the storage resource is also related to the computing resource, please view the specification document for more information.

Examples:
storage:
size: number, optional # in megabyte
object({
size = optional(number, 20 * 1024)
})
{
"size": 20480
}
no
username Specify the account username. The username must be 1-63 characters long and start with lower letter, combined with number.
The username cannot be MySQL forbidden keyword and azure_superuser, admin, administrator, root, guest or public.
string "rdsuser" no

Outputs

Name Description
address The address, a string only has host, might be a comma separated string or a single string.
address_readonly The readonly address, a string only has host, might be a comma separated string or a single string.
connection The connection, a string combined host and port, might be a comma separated string or a single string.
connection_readonly The readonly connection, a string combined host and port, might be a comma separated string or a single string.
context The input context, a map, which is used for orchestration.
database The name of MySQL database to access.
password The password of the account to access the database.
port The port of the service.
refer The refer, a map, including hosts, ports and account, which is used for dependencies or collaborations.
username The username of the account to access the database.