|
| 1 | +# Azure Database for MySQL Terraform Module |
| 2 | + |
| 3 | +Azure Database for MySQL is easy to set up, manage and scale. It automates the management and maintenance of your infrastructure and database server, including routine updates, backups and security. Enjoy maximum control of database management with custom maintenance windows and multiple configuration parameters for fine grained tuning with Flexible Server (Preview). |
| 4 | + |
| 5 | +## Module Usage |
| 6 | + |
| 7 | +```hcl |
| 8 | +module "mssql-server" { |
| 9 | + source = "kumarvna/mysql-db/azurerm" |
| 10 | + version = "1.0.0" |
| 11 | +
|
| 12 | + # By default, this module will not create a resource group |
| 13 | + # proivde a name to use an existing resource group, specify the existing resource group name, |
| 14 | + # and set the argument to `create_resource_group = false`. Location will be same as existing RG. |
| 15 | + create_resource_group = false |
| 16 | + resource_group_name = "rg-shared-westeurope-01" |
| 17 | + location = "westeurope" |
| 18 | +
|
| 19 | + # MySQL Server and Database settings |
| 20 | + mysqlserver_name = "roshmysqldbsrv01" |
| 21 | +
|
| 22 | + mysqlserver_settings = { |
| 23 | + sku_name = "B_Gen5_2" |
| 24 | + storage_mb = 5120 |
| 25 | + version = "5.7" |
| 26 | + # Database name, charset and collection arguments |
| 27 | + database_name = "roshydemomysqldb" |
| 28 | + charset = "utf8" |
| 29 | + collation = "utf8_unicode_ci" |
| 30 | + # Storage Profile and other optional arguments |
| 31 | + auto_grow_enabled = true |
| 32 | + backup_retention_days = 7 |
| 33 | + geo_redundant_backup_enabled = false |
| 34 | + infrastructure_encryption_enabled = false |
| 35 | + public_network_access_enabled = true |
| 36 | + ssl_enforcement_enabled = true |
| 37 | + ssl_minimal_tls_version_enforced = "TLS1_2" |
| 38 | + } |
| 39 | +
|
| 40 | + # MySQL Server Parameters |
| 41 | + # For more information: https://docs.microsoft.com/en-us/azure/mysql/concepts-server-parameters |
| 42 | + mysql_configuration = { |
| 43 | + interactive_timeout = "600" |
| 44 | + } |
| 45 | +
|
| 46 | + # AD administrator for an Azure SQL server |
| 47 | + # Allows you to set a user or group as the AD administrator for an Azure SQL server |
| 48 | + ad_admin_login_name = "firstname.lastname@example.com" |
| 49 | +
|
| 50 | + # (Optional) To enable Azure Monitoring for Azure MySQL database |
| 51 | + # (Optional) Specify `storage_account_name` to save monitoring logs to storage. |
| 52 | + log_analytics_workspace_name = "loganalytics-we-sharedtest2" |
| 53 | +
|
| 54 | + # Firewall Rules to allow azure and external clients and specific Ip address/ranges. |
| 55 | +
|
| 56 | + firewall_rules = { |
| 57 | + access-to-azure = { |
| 58 | + start_ip_address = "0.0.0.0" |
| 59 | + end_ip_address = "0.0.0.0" |
| 60 | + }, |
| 61 | + desktop-ip = { |
| 62 | + start_ip_address = "49.204.228.223" |
| 63 | + end_ip_address = "49.204.228.223" |
| 64 | + } |
| 65 | + } |
| 66 | +
|
| 67 | + # Tags for Azure Resources |
| 68 | + tags = { |
| 69 | + Terraform = "true" |
| 70 | + Environment = "dev" |
| 71 | + Owner = "test-user" |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## Terraform Usage |
| 77 | + |
| 78 | +To run this example you need to execute following Terraform commands |
| 79 | + |
| 80 | +```hcl |
| 81 | +terraform init |
| 82 | +
|
| 83 | +terraform plan |
| 84 | +
|
| 85 | +terraform apply |
| 86 | +``` |
| 87 | + |
| 88 | +Run `terraform destroy` when you don't need these resources. |
0 commit comments