diff --git a/README.md b/README.md index b905f08..6d4966a 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" @@ -105,6 +109,12 @@ module "mysql-db" { } ``` +## Default Local Administrator and the Password + +This module utilizes __`sqladmin`__ as a local administrator on MySQL server. If you want to you use custom username, then specify the same by setting up the argument `admin_username` with a valid user string. + +By default, this module generates a strong password for MySQL server also allows you to change the length of the random password (currently 24) using the `random_password_length` variable. If you want to set the custom password, specify the argument `admin_password` with a valid string. + ## `mysql_setttings` - Setting up your MySQL Server This object helps you setup desired MySQL server and support following arguments. @@ -237,6 +247,9 @@ An effective naming convention assembles resource names by using important resou `admin_password`|The Password which should be used for the local-administrator on this SQL Server|string|`null` `identity`|If you want your SQL Server to have an managed identity. Defaults to false|string|`false` `mysqlserver_settings`|MySQL server settings|object({})|`{}` +`create_mode`|The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`|string|`Default` +`creation_source_server_id`|For creation modes other than `Default`, the source server ID to use|string|`null` +`restore_point_in_time`|When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`|string|`null` `storage_account_name`|The name of the storage account name|string|`null` `enable_threat_detection_policy`|Threat detection policy configuration, known in the API as Server Security Alerts Policy|string|`false` `email_addresses_for_alerts`|Account administrators email for alerts|`list(any)`|`""` diff --git a/examples/MySQL_Server/README.md b/examples/MySQL_Server/README.md index 9e511d1..04bf102 100644 --- a/examples/MySQL_Server/README.md +++ b/examples/MySQL_Server/README.md @@ -24,6 +24,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" diff --git a/examples/MySQL_Server/main.tf b/examples/MySQL_Server/main.tf index 0130013..b035621 100644 --- a/examples/MySQL_Server/main.tf +++ b/examples/MySQL_Server/main.tf @@ -17,6 +17,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" diff --git a/examples/MySQL_Server_with_Private_Endpoint/README.md b/examples/MySQL_Server_with_Private_Endpoint/README.md index c317f3b..e3bf33d 100644 --- a/examples/MySQL_Server_with_Private_Endpoint/README.md +++ b/examples/MySQL_Server_with_Private_Endpoint/README.md @@ -24,6 +24,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" diff --git a/examples/MySQL_Server_with_Private_Endpoint/main.tf b/examples/MySQL_Server_with_Private_Endpoint/main.tf index 542e266..2174e30 100644 --- a/examples/MySQL_Server_with_Private_Endpoint/main.tf +++ b/examples/MySQL_Server_with_Private_Endpoint/main.tf @@ -18,6 +18,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" diff --git a/examples/README.md b/examples/README.md index ec468ab..4d09657 100644 --- a/examples/README.md +++ b/examples/README.md @@ -24,6 +24,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" @@ -106,6 +110,10 @@ module "mysql-db" { sku_name = "GP_Gen5_16" storage_mb = 5120 version = "5.7" + # default admin user `sqladmin` and can be specified as per the choice here + # by default random password created by this module. required password can be specified here + admin_username = "sqladmin" + admin_password = "H@Sh1CoR3!" # Database name, charset and collection arguments database_name = "demomysqldb" charset = "utf8" diff --git a/main.tf b/main.tf index 8dc6e98..2f2a35f 100644 --- a/main.tf +++ b/main.tf @@ -94,6 +94,9 @@ resource "azurerm_mysql_server" "main" { public_network_access_enabled = var.mysqlserver_settings.public_network_access_enabled ssl_enforcement_enabled = var.mysqlserver_settings.ssl_enforcement_enabled ssl_minimal_tls_version_enforced = var.mysqlserver_settings.ssl_minimal_tls_version_enforced + create_mode = var.create_mode + creation_source_server_id = var.create_mode != "Default" ? var.creation_source_server_id : null + restore_point_in_time = var.create_mode == "PointInTimeRestore" ? var.restore_point_in_time : null tags = merge({ "Name" = format("%s", var.mysqlserver_name) }, var.tags, ) dynamic "identity" { diff --git a/variables.tf b/variables.tf index e8a3c77..bf6211b 100644 --- a/variables.tf +++ b/variables.tf @@ -67,6 +67,21 @@ variable "mysqlserver_settings" { }) } +variable "create_mode" { + description = "The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`. Defaults to `Default`" + default = "Default" +} + +variable "creation_source_server_id" { + description = "For creation modes other than `Default`, the source server ID to use." + default = null +} + +variable "restore_point_in_time" { + description = "When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`" + default = null +} + variable "storage_account_name" { description = "The name of the storage account name" default = null