Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)`|`""`
Expand Down
4 changes: 4 additions & 0 deletions examples/MySQL_Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions examples/MySQL_Server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions examples/MySQL_Server_with_Private_Endpoint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions examples/MySQL_Server_with_Private_Endpoint/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
15 changes: 15 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down