Terraform module to create flexible-mysql resource on AZURE.
We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.
This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.
This module has a few dependencies:
IMPORTANT: Since the master
branch used in source
varies based on new modifications, we suggest that you use the release versions here.
Here is an example of how you can use this module in your inventory structure:
module "flexible-mysql" {
source = "clouddrove/flexible-mysql/azure"
name = "app"
environment = "test"
label_order = ["environment", "name"]
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_id = module.vnet.vnet_id[0]
delegated_subnet_id = module.subnet.default_subnet_id[0]
mysql_version = "8.0.21"
mysql_server_name = "testmysqlserver"
private_dns = true
zone = "1"
admin_username = "mysqlusername"
admin_password = "ba5yatgfgfhdsv6A3ns2lu4gqzzc"
sku_name = "GP_Standard_D8ds_v4"
db_name = "maindb"
charset = "utf8"
collation = "utf8_unicode_ci"
server_configuration_name = "interactive_timeout"
auto_grow_enabled = true
iops = 360
size_gb = "20"
}
##for mysql replication
module "flexible-mysql" {
source = "clouddrove/flexible-mysql/azure"
name = "app"
environment = "test"
label_order = ["environment", "name"]
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.vnet_id[0]
delegated_subnet_id = module.subnet.default_subnet_id[0]
mysql_version = "8.0.21"
mysql_server_name = "testmysqlserver"
zone = "1"
admin_username = "mysqlusern"
admin_password = "ba5yatgfgfhdsvvc6A3ns2lu4gqzzc"
sku_name = "GP_Standard_D8ds_v4"
db_name = "maindb"
charset = "utf8"
collation = "utf8_unicode_ci"
server_configuration_name = "interactive_timeout"
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
}
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 |
enable_diagnostic | Set to false to prevent the module from creating any resources. | bool |
true |
no |
enable_private_endpoint | Manages a Private Endpoint to Azure database for MySQL | bool |
false |
no |
enabled | Set to false to prevent the module from creating any resources. | bool |
true |
no |
end_ip_address | n/a | string |
"" |
no |
environment | Environment (e.g. prod , dev , staging ). |
string |
"" |
no |
eventhub_authorization_rule_id | Eventhub authorization rule id to pass it to destination details of diagnosys setting of NSG. | string |
null |
no |
eventhub_name | Eventhub Name to pass it to destination details of diagnosys setting of NSG. | string |
null |
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_id | Specifies the URL to a Key Vault Key (either from a Key Vault Key, or the Key URL for the Key Vault Secret | string |
"" |
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 |
log_analytics_destination_type | Possible values are AzureDiagnostics and Dedicated, default to AzureDiagnostics. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table. | string |
"AzureDiagnostics" |
no |
log_analytics_workspace_id | Log Analytics workspace id in which logs should be retained. | string |
null |
no |
log_category | Categories of logs to be recorded in diagnostic setting. Acceptable values are MySqlSlowLogs , MySqlAuditLogs | list(string) |
[ |
no |
main_rg_name | n/a | string |
"" |
no |
managedby | ManagedBy, eg ''. | string |
"" |
no |
metric_enabled | Whether metric diagnonsis should be enable in diagnostic settings for flexible Mysql. | bool |
true |
no |
mysql_server_name | n/a | 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 | string |
"" |
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 |
start_ip_address | n/a | string |
"" |
no |
storage_account_id | Storage account id to pass it to destination details of diagnosys setting of NSG. | 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. |
In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.
You need to run the following command in the testing folder:
go test -run Test
If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at hello@clouddrove.com.
If you have found it worth your time, go ahead and give us a ★ on our GitHub!
At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
We are The Cloud Experts!
We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.