Skip to content

Terraform module composition (feature) for Azure MariaDB Database

License

Notifications You must be signed in to change notification settings

claranet/terraform-azurerm-db-maria

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Mariadb

Changelog Notice Apache V2 License OpenTofu Registry

This module creates a MariaDB Server with one or several databases.

⚠ This module is deprecated, as Microsoft will withdraw this resource in 2025. Please consider moving to our Azure MySQL Flexible module.

Global versioning rule for Claranet Azure modules

Module version Terraform version OpenTofu version AzureRM version
>= 8.x.x Unverified 1.8.x >= 4.0
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.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

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

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.

⚠️ Since modules version v8.0.0, we do not maintain/check anymore the compatibility with Hashicorp Terraform. Instead, we recommend to use OpenTofu.

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/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 "db_maria" {
  source  = "claranet/db-maria/azurerm"
  version = "x.x.x"

  client_name    = var.client_name
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  environment    = var.environment
  stack          = var.stack

  resource_group_name = module.rg.resource_group_name

  tier     = "GeneralPurpose"
  capacity = 4

  authorized_cidrs = {
    rule1 = "10.0.0.0/24"
    rule2 = "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

  force_ssl = true

  databases_names     = ["mydatabase"]
  databases_collation = { mydatabase = "utf8_general_ci" }
  databases_charset   = { mydatabase = "utf8" }

  logs_destinations_ids = [
    module.logs.logs_storage_account_id,
    module.logs.log_analytics_workspace_id
  ]

  extra_tags = {
    foo = "bar"
  }
}

locals {
  administrator_login = format("%s@%s", module.db_maria.mariadb_administrator_login, module.db_maria.mariadb_server_name)
}

provider "mysql" {
  endpoint = format("%s:3306", module.db_maria.mariadb_fqdn)
  username = local.administrator_login
  password = module.db_maria.mariadb_administrator_password

  tls = true
}

module "mysql_users" {
  source  = "claranet/users/mysql"
  version = "x.x.x"

  for_each = toset(module.db_maria.mariadb_databases_names)

  user_suffix_enabled = true
  user                = each.key
  database            = each.key
}

Providers

Name Version
azurecaf ~> 1.2, >= 1.2.22
azurerm >= 3.47
random ~> 3.0

Modules

Name Source Version
diagnostics claranet/diagnostic-settings/azurerm ~> 6.5.0

Resources

Name Type
azurerm_mariadb_configuration.mariadb_config resource
azurerm_mariadb_database.mariadb_db resource
azurerm_mariadb_firewall_rule.mariadb_fw_rule resource
azurerm_mariadb_server.mariadb_server resource
azurerm_mariadb_virtual_network_rule.vnet_rules resource
random_password.mariadb_administrator_password resource
azurecaf_name.mariadb data source
azurecaf_name.mariadb_dbs data source

Inputs

Name Description Type Default Required
administrator_login MariaDB administrator login. string "dbadmin" no
administrator_password MariaDB administrator password. Auto-generated if empty. Strong Password: https://docs.microsoft.com/en-us/sql/relational-databases/security/strong-passwords?view=sql-server-2017 string "" no
authorized_cidrs Map of authorized CIDRs (keys are rule names). 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 MariaDB server SKU: https://www.terraform.io/docs/providers/azurerm/r/mariadb_server.html#sku_name number 4 no
client_name Client name/account used in naming. string n/a yes
custom_diagnostic_settings_name Custom name of the diagnostics settings, name will be 'default' if not set. string "default" no
custom_server_name Custom Server Name identifier string "" no
databases_charset Specifies the charset for each MariaDB Database: https://mariadb.com/kb/en/library/setting-character-sets-and-collations/ map(string) {} no
databases_collation Specifies the collation for each MariaDB Database: https://mariadb.com/kb/en/library/setting-character-sets-and-collations/ map(string) {} no
databases_names List of databases names list(string) n/a yes
default_tags_enabled Option to enable or disable default tags bool true no
environment Project/Application environment. string n/a yes
extra_tags Extra tags to add map(string) {} no
force_min_tls_version Specifies which minimal SSL version should be enforced on connections. string "TLS1_2" no
force_ssl Specifies if SSL should be enforced on connections. 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 region to use. 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 diagnostic destination.
Can be Storage Account, Log Analytics Workspace and Event Hub. No more than one of each can be set.
If you want to specify an Azure EventHub to send logs and metrics to, you need to provide a formated string with both the EventHub Namespace authorization send ID and the EventHub name (name of the queue to use in the Namespace) separated by the `
` character. list(string) n/a
logs_metrics_categories Metrics categories to send to destinations. list(string) null no
mariadb_configurations MariaDB configurations to enable. map(string) {} no
mariadb_version Specifies the version of MariaDB to use. Possible values are 10.2 and 10.3 string "10.2" no
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
public_network_access_enabled Enable public network access for this MariaDB server. bool false no
resource_group_name Name of the application ressource group. string n/a yes
stack Project/Application 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
tier Tier for MariaDB server SKU: https://www.terraform.io/docs/providers/azurerm/r/mariadb_server.html#sku_name Possible values are: GeneralPurpose, Basic, MemoryOptimized string "GeneralPurpose" no
use_caf_naming Use the Azure CAF naming provider to generate default resource name. custom_server_name override this if set. Legacy default name is used if this is set to false. bool true no
use_caf_naming_for_databases Use the Azure CAF naming provider to generate databases name. bool false no
vnet_rules Map of VNet rules to create (keys are rule names, values are Subnet IDs). map(string) {} no

Outputs

Name Description
mariadb_administrator_login Administrator login for mariadb server
mariadb_administrator_password Administrator password for mariadb server
mariadb_configurations The map of all mariadb configurations set
mariadb_database_ids List of all database resource ids
mariadb_databases Map of databases infos
mariadb_databases_names List of databases names
mariadb_firewall_rules Map of mariadb created rules
mariadb_fqdn FQDN of the mariadb server
mariadb_server_id mariadb server ID
mariadb_server_name mariadb server name
mariadb_vnet_rules The map of all vnet rules
terraform_module Information about this Terraform module

Related documentation

Microsoft Azure documentation: docs.microsoft.com/fr-fr/azure/mariadb/overview

About

Terraform module composition (feature) for Azure MariaDB Database

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages