This Terraform module creates an Azure MySQL server with databases and associated admin users along with logging activated and firewall rules.
- MySQL Terraform provider >= 1.6
Module version | Terraform version | AzureRM version |
---|---|---|
>= 5.x.x | 0.15.x & 1.0.x | >= 2.0 |
>= 4.x.x | 0.13.x | >= 2.0 |
>= 3.x.x | 0.12.x | >= 2.0 |
>= 2.x.x | 0.12.x | < 2.0 |
< 2.x.x | 0.11.x | < 2.0 |
This module is optimized to work with the Claranet terraform-wrapper tool
which set some terraform variables in the environment needed by this module.
More details about variables set by the terraform-wrapper
available in the documentation.
module "azure_region" {
source = "claranet/regions/azurerm"
version = "x.x.x"
azure_region = var.azure_region
}
module "rg" {
source = "claranet/rg/azurerm"
version = "x.x.x"
location = module.azure_region.location
client_name = var.client_name
environment = var.environment
stack = var.stack
}
module "logs" {
source = "claranet/run-common/azurerm//modules/logs"
version = "x.x.x"
client_name = var.client_name
environment = var.environment
stack = var.stack
location = module.azure_region.location
location_short = module.azure_region.location_short
resource_group_name = module.rg.resource_group_name
}
module "mysql" {
source = "claranet/db-mysql/azurerm"
version = "x.x.x"
client_name = var.client_name
environment = var.environment
location = module.azure_region.location
location_short = module.azure_region.location_short
stack = var.stack
resource_group_name = module.rg.resource_group_name
tier = "GeneralPurpose"
capacity = 4
allowed_cidrs = {
peered-vnet = "10.0.0.0/24",
customer-office = "12.34.56.78/32"
}
storage_mb = 5120
backup_retention_days = 10
geo_redundant_backup_enabled = true
auto_grow_enabled = false
administrator_login = var.administrator_login
administrator_password = var.administrator_password
databases = {
"documents" = {
"charset" = "utf8"
"collation" = "utf8_general_ci"
}
}
force_ssl = true
mysql_options = {
interactive_timeout = "600",
wait_timeout = "260"
}
mysql_version = "5.7"
threat_detection_policy = {
email_addresses = ["[email protected]"]
}
logs_destinations_ids = [
module.logs.logs_storage_account_id,
module.logs.log_analytics_workspace_id
]
extra_tags = {
foo = "bar"
}
}
Name | Version |
---|---|
azurerm | >= 2.23 |
mysql.users_mgmt | >=1.10.4 |
random | >= 2.0 |
Name | Source | Version |
---|---|---|
diagnostics | claranet/diagnostic-settings/azurerm | 4.0.3 |
Name | Type |
---|---|
azurerm_mysql_configuration.mysql_config | resource |
azurerm_mysql_database.mysql_db | resource |
azurerm_mysql_firewall_rule.firewall_rules | resource |
azurerm_mysql_server.mysql_server | resource |
azurerm_mysql_virtual_network_rule.vnet_rules | resource |
mysql_grant.roles | resource |
mysql_user.users | resource |
random_password.db_passwords | resource |
random_password.mysql_administrator_password | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
administrator_login | MySQL administrator login | string |
n/a | yes |
administrator_password | MySQL administrator password. If not set, randomly generated | string |
"" |
no |
allowed_cidrs | Map of authorized cidrs | map(string) |
n/a | yes |
allowed_subnets | Map of authorized subnet ids | map(string) |
{} |
no |
auto_grow_enabled | Enable/Disable auto-growing of the storage. | bool |
false |
no |
backup_retention_days | Backup retention days for the server, supported values are between 7 and 35 days. | number |
10 |
no |
capacity | Capacity for MySQL server sku: https://www.terraform.io/docs/providers/azurerm/r/mysql_server.html#capacity | number |
4 |
no |
client_name | Client name/account used in naming | string |
n/a | yes |
create_databases_users | True to create a user named (_user) per database with generated password. | bool |
true |
no |
custom_server_name | Custom Server Name identifier | string |
"" |
no |
databases | Map of databases with default collation and charset | map(map(string)) |
n/a | yes |
environment | Project environment | string |
n/a | yes |
extra_tags | Map of custom tags | map(string) |
{} |
no |
force_ssl | Enforce SSL connection | bool |
true |
no |
geo_redundant_backup_enabled | Turn Geo-redundant server backups on/off. Not available for the Basic tier. | bool |
true |
no |
location | Azure location. | string |
n/a | yes |
location_short | Short string for Azure location. | string |
n/a | yes |
logs_categories | Log categories to send to destinations. | list(string) |
null |
no |
logs_destinations_ids | List of destination resources Ids for logs diagnostics destination. Can be Storage Account, Log Analytics Workspace and Event Hub. No more than one of each can be set. Empty list to disable logging. | list(string) |
n/a | yes |
logs_metrics_categories | Metrics categories to send to destinations. | list(string) |
null |
no |
logs_retention_days | Number of days to keep logs on storage account | number |
30 |
no |
mysql_options | Map of configuration options: https://docs.microsoft.com/fr-fr/azure/mysql/howto-server-parameters#list-of-configurable-server-parameters | map(string) |
{} |
no |
mysql_version | Valid values are 5.6, 5.7 and 8.0 | string |
"5.7" |
no |
name_prefix | Optional prefix for the generated name | string |
"" |
no |
public_network_access_enabled | Enable public network access for this server | bool |
true |
no |
resource_group_name | Resource group name | string |
n/a | yes |
stack | Project stack name | string |
n/a | yes |
storage_mb | Max storage allowed for a server. Possible values are between 5120 MB(5GB) and 1048576 MB(1TB) for the Basic SKU and between 5120 MB(5GB) and 4194304 MB(4TB) for General Purpose/Memory Optimized SKUs. | number |
5120 |
no |
threat_detection_policy | Threat detection policy configuration, known in the API as Server Security Alerts Policy | any |
null |
no |
tier | Tier for MySQL server sku: https://www.terraform.io/docs/providers/azurerm/r/mysql_server.html#tier Possible values are: GeneralPurpose, Basic, MemoryOptimized. |
string |
"GeneralPurpose" |
no |
user_suffix | Suffix to append to the created users | string |
"_user" |
no |
Name | Description |
---|---|
mysql_administrator_login | Administrator login for MySQL server |
mysql_administrator_password | Administrator password for mysql server |
mysql_database_ids | The list of all database resource ids |
mysql_databases | Map of databases infos |
mysql_databases_logins | Map of user login for each database |
mysql_databases_names | List of databases names |
mysql_databases_passwords | Map of user password for each database |
mysql_databases_users | Map of user name for each database |
mysql_firewall_rule_ids | Map of MySQL created rules |
mysql_fqdn | FQDN of the MySQL server |
mysql_server_id | MySQL server ID |
mysql_server_name | MySQL server name |
mysql_vnet_rules | The map of all vnet rules |
Microsoft Azure documentation: docs.microsoft.com/fr-fr/azure/mysql/overview