This repository contains Terraform code to deploy resources on Microsoft Azure, including a resource group and a virtual network and flexible-mysql.
To use this module, you should have Terraform installed and configured for AZURE. This module provides the necessary Terraform configuration for creating AZURE resources, and you can customize the inputs as needed. Below is an example of how to use this module:
module "flexible-mysql" {
depends_on = [module.resource_group, module.vnet]
source = "git::https://github.com/opsstation/terraform-azure-flexible-mysql.git?ref=v1.0.0"
name = local.name
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_id = module.vnet.id
delegated_subnet_id = [module.subnet.default_subnet_id][0]
mysql_version = "8.0.21"
private_dns = true
zone = "1"
admin_username = "mysqlusername"
admin_password = "ba5yatgfgfhdsv6A3ns2lu4gqzzc"
sku_name = "GP_Standard_D8ds_v4"
db_name = "maindb"
charset = "utf8mb3"
collation = "utf8mb3_unicode_ci"
auto_grow_enabled = true
iops = 360
size_gb = "20"
#azurerm_mysql_flexible_server_configuration
server_configuration_names = ["interactive_timeout", "audit_log_enabled"]
values = ["600", "ON"]
}
module "flexible-mysql-replication" {
depends_on = [module.resource_group, module.vnet, data.azurerm_resource_group.main]
source = "git::https://github.com/opsstation/terraform-azure-flexible-mysql.git?ref=v1.0.0"
name = local.name
environment = local.environment
main_rg_name = data.azurerm_resource_group.main.name
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_id = module.vnet.id
delegated_subnet_id = [module.subnet.default_subnet_id][0]
mysql_version = "8.0.21"
zone = "1"
admin_username = "mysqlusern"
admin_password = "ba5yatgfgfhdsvvc6A3ns2lu4gqzzc"
sku_name = "GP_Standard_D8ds_v4"
db_name = "maindb"
charset = "utf8"
collation = "utf8_unicode_ci"
auto_grow_enabled = true
iops = 360
size_gb = "20"
existing_private_dns_zone = true
existing_private_dns_zone_id = data.azurerm_private_dns_zone.main.id
existing_private_dns_zone_name = data.azurerm_private_dns_zone.main.name
##azurerm_mysql_flexible_server_configuration
server_configuration_names = ["interactive_timeout", "audit_log_enabled"]
values = ["600", "ON"]
}
This example demonstrates how to create various AZURE resources using the provided modules. Adjust the input values to suit your specific requirements.
For detailed examples on how to use this module, please refer to the examples directory within this repository.
This Terraform module is provided under the MIT License. Please see the LICENSE file for more details.
Your Name Replace MIT and Cypik with the appropriate license and your information. Feel free to expand this README with additional details or usage instructions as needed for your specific use case.
Name | Version |
---|---|
terraform | >= 1.3.6 |
azurerm | >=3.0.0 |
random | >= 3.0, < 4.0 |
Name | Version |
---|---|
azurerm | >=3.0.0 |
random | >= 3.0, < 4.0 |
Name | Source | Version |
---|---|---|
labels | git::https://github.com/opsstation/terraform-azure-labels.git | v1.0.0 |
Name | Type |
---|---|
azurerm_mysql_flexible_database.main | resource |
azurerm_mysql_flexible_server.main | resource |
azurerm_mysql_flexible_server_configuration.main | resource |
azurerm_mysql_server_key.main | resource |
azurerm_private_dns_zone.main | resource |
azurerm_private_dns_zone_virtual_network_link.main | resource |
azurerm_private_dns_zone_virtual_network_link.main2 | resource |
random_password.main | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
admin_password | The password associated with the admin_username user | string |
null |
no |
admin_password_length | Length of random password generated. | number |
16 |
no |
admin_username | The administrator login name for the new SQL Server | any |
null |
no |
auto_grow_enabled | Should Storage Auto Grow be enabled? Defaults to true. | bool |
false |
no |
backup_retention_days | The backup retention days for the MySQL Flexible Server. Possible values are between 1 and 35 days. Defaults to 7 | number |
7 |
no |
charset | Specifies the Charset for the MySQL Database, which needs to be a valid MySQL Charset. Changing this forces a new resource to be created. | string |
"" |
no |
collation | Specifies the Collation for the MySQL Database, which needs to be a valid MySQL Collation. Changing this forces a new resource to be created. | string |
"" |
no |
create_mode | The creation mode. Can be used to restore or replicate existing servers. Possible values are Default , Replica , GeoRestore , and PointInTimeRestore . Defaults to Default |
string |
"Default" |
no |
db_name | Specifies the name of the MySQL Database, which needs to be a valid MySQL identifier. Changing this forces a new resource to be created. | string |
"" |
no |
delegated_subnet_id | The resource ID of the subnet | string |
"" |
no |
enabled | Set to false to prevent the module from creating any resources. | bool |
true |
no |
environment | Environment (e.g. prod , dev , staging ). |
string |
"" |
no |
existing_private_dns_zone | Name of the existing private DNS zone | bool |
false |
no |
existing_private_dns_zone_id | n/a | string |
"" |
no |
existing_private_dns_zone_name | The name of the Private DNS zone (without a terminating dot). Changing this forces a new resource to be created. | string |
"" |
no |
geo_redundant_backup_enabled | Should geo redundant backup enabled? Defaults to false. Changing this forces a new MySQL Flexible Server to be created. | bool |
true |
no |
high_availability | Map of high availability configuration: https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-high-availability. null to disable high availability |
object({ |
{ |
no |
iops | The storage IOPS for the MySQL Flexible Server. Possible values are between 360 and 20000. | number |
360 |
no |
key_vault_key_id | The URL to a Key Vault Key | string |
null |
no |
label_order | Label order, e.g. sequence of application name and environment name ,environment ,'attribute' [webserver ,qa ,devops ,public ,] . |
list(any) |
[ |
no |
location | The Azure Region where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created. | string |
"" |
no |
main_rg_name | n/a | string |
"" |
no |
managedby | ManagedBy, eg 'opsstation'. | string |
"" |
no |
mysql_version | The version of the MySQL Flexible Server to use. Possible values are 5.7, and 8.0.21. Changing this forces a new MySQL Flexible Server to be created. | string |
"5.7" |
no |
name | Name (e.g. app or cluster ). |
string |
"" |
no |
point_in_time_restore_time_in_utc | The point in time to restore from creation_source_server_id when create_mode is PointInTimeRestore. Changing this forces a new MySQL Flexible Server to be created. | string |
null |
no |
private_dns | n/a | bool |
false |
no |
registration_enabled | Is auto-registration of virtual machine records in the virtual network in the Private DNS zone enabled | bool |
false |
no |
replication_role | The replication role. Possible value is None. | string |
null |
no |
repository | Terraform current module repo | string |
"" |
no |
resource_group_name | A container that holds related resources for an Azure solution | any |
"" |
no |
server_configuration_names | Specifies the name of the MySQL Flexible Server Configuration, which needs to be a valid MySQL configuration name. Changing this forces a new resource to be created. | list(string) |
[] |
no |
size_gb | The max storage allowed for the MySQL Flexible Server. Possible values are between 20 and 16384. | string |
"20" |
no |
sku_name | The SKU Name for the MySQL Flexible Server. | string |
"GP_Standard_D8ds_v4" |
no |
source_server_id | The resource ID of the source MySQL Flexible Server to be restored. Required when create_mode is PointInTimeRestore, GeoRestore, and Replica. Changing this forces a new MySQL Flexible Server to be created. | string |
null |
no |
values | Specifies the value of the MySQL Flexible Server Configuration. See the MySQL documentation for valid values. Changing this forces a new resource to be created. | list(string) |
[] |
no |
virtual_network_id | The name of the virtual network | string |
"" |
no |
zone | Specifies the Availability Zone in which this MySQL Flexible Server should be located. Possible values are 1, 2 and 3. | number |
null |
no |
Name | Description |
---|---|
azurerm_mysql_flexible_server_configuration_id | The ID of the MySQL Flexible Server Configuration. |
azurerm_private_dns_zone_id | The Private DNS Zone ID. |
azurerm_private_dns_zone_virtual_network_link_id | The ID of the Private DNS Zone Virtual Network Link. |
existing_private_dns_zone_virtual_network_link_id | The ID of the Private DNS Zone Virtual Network Link. |
mysql_flexible_server_id | The ID of the MySQL Flexible Server. |