Skip to content

Commit 023a0f3

Browse files
authored
Merge pull request #3 from kumarvna/develop
final configuration for version 1.1.0
2 parents 2e9c33d + 1ace107 commit 023a0f3

File tree

8 files changed

+55
-0
lines changed

8 files changed

+55
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ module "mysql-db" {
3737
sku_name = "GP_Gen5_16"
3838
storage_mb = 5120
3939
version = "5.7"
40+
# default admin user `sqladmin` and can be specified as per the choice here
41+
# by default random password created by this module. required password can be specified here
42+
admin_username = "sqladmin"
43+
admin_password = "H@Sh1CoR3!"
4044
# Database name, charset and collection arguments
4145
database_name = "demomysqldb"
4246
charset = "utf8"
@@ -105,6 +109,12 @@ module "mysql-db" {
105109
}
106110
```
107111

112+
## Default Local Administrator and the Password
113+
114+
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.
115+
116+
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.
117+
108118
## `mysql_setttings` - Setting up your MySQL Server
109119

110120
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
237247
`admin_password`|The Password which should be used for the local-administrator on this SQL Server|string|`null`
238248
`identity`|If you want your SQL Server to have an managed identity. Defaults to false|string|`false`
239249
`mysqlserver_settings`|MySQL server settings|object({})|`{}`
250+
`create_mode`|The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`|string|`Default`
251+
`creation_source_server_id`|For creation modes other than `Default`, the source server ID to use|string|`null`
252+
`restore_point_in_time`|When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`|string|`null`
240253
`storage_account_name`|The name of the storage account name|string|`null`
241254
`enable_threat_detection_policy`|Threat detection policy configuration, known in the API as Server Security Alerts Policy|string|`false`
242255
`email_addresses_for_alerts`|Account administrators email for alerts|`list(any)`|`""`

examples/MySQL_Server/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module "mysql-db" {
2424
sku_name = "GP_Gen5_16"
2525
storage_mb = 5120
2626
version = "5.7"
27+
# default admin user `sqladmin` and can be specified as per the choice here
28+
# by default random password created by this module. required password can be specified here
29+
admin_username = "sqladmin"
30+
admin_password = "H@Sh1CoR3!"
2731
# Database name, charset and collection arguments
2832
database_name = "demomysqldb"
2933
charset = "utf8"

examples/MySQL_Server/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module "mysql-db" {
1717
sku_name = "GP_Gen5_16"
1818
storage_mb = 5120
1919
version = "5.7"
20+
# default admin user `sqladmin` and can be specified as per the choice here
21+
# by default random password created by this module. required password can be specified here
22+
admin_username = "sqladmin"
23+
admin_password = "H@Sh1CoR3!"
2024
# Database name, charset and collection arguments
2125
database_name = "demomysqldb"
2226
charset = "utf8"

examples/MySQL_Server_with_Private_Endpoint/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module "mysql-db" {
2424
sku_name = "GP_Gen5_16"
2525
storage_mb = 5120
2626
version = "5.7"
27+
# default admin user `sqladmin` and can be specified as per the choice here
28+
# by default random password created by this module. required password can be specified here
29+
admin_username = "sqladmin"
30+
admin_password = "H@Sh1CoR3!"
2731
# Database name, charset and collection arguments
2832
database_name = "demomysqldb"
2933
charset = "utf8"

examples/MySQL_Server_with_Private_Endpoint/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ module "mysql-db" {
1818
sku_name = "GP_Gen5_16"
1919
storage_mb = 5120
2020
version = "5.7"
21+
# default admin user `sqladmin` and can be specified as per the choice here
22+
# by default random password created by this module. required password can be specified here
23+
admin_username = "sqladmin"
24+
admin_password = "H@Sh1CoR3!"
2125
# Database name, charset and collection arguments
2226
database_name = "demomysqldb"
2327
charset = "utf8"

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module "mysql-db" {
2424
sku_name = "GP_Gen5_16"
2525
storage_mb = 5120
2626
version = "5.7"
27+
# default admin user `sqladmin` and can be specified as per the choice here
28+
# by default random password created by this module. required password can be specified here
29+
admin_username = "sqladmin"
30+
admin_password = "H@Sh1CoR3!"
2731
# Database name, charset and collection arguments
2832
database_name = "demomysqldb"
2933
charset = "utf8"
@@ -106,6 +110,10 @@ module "mysql-db" {
106110
sku_name = "GP_Gen5_16"
107111
storage_mb = 5120
108112
version = "5.7"
113+
# default admin user `sqladmin` and can be specified as per the choice here
114+
# by default random password created by this module. required password can be specified here
115+
admin_username = "sqladmin"
116+
admin_password = "H@Sh1CoR3!"
109117
# Database name, charset and collection arguments
110118
database_name = "demomysqldb"
111119
charset = "utf8"

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ resource "azurerm_mysql_server" "main" {
9494
public_network_access_enabled = var.mysqlserver_settings.public_network_access_enabled
9595
ssl_enforcement_enabled = var.mysqlserver_settings.ssl_enforcement_enabled
9696
ssl_minimal_tls_version_enforced = var.mysqlserver_settings.ssl_minimal_tls_version_enforced
97+
create_mode = var.create_mode
98+
creation_source_server_id = var.create_mode != "Default" ? var.creation_source_server_id : null
99+
restore_point_in_time = var.create_mode == "PointInTimeRestore" ? var.restore_point_in_time : null
97100
tags = merge({ "Name" = format("%s", var.mysqlserver_name) }, var.tags, )
98101

99102
dynamic "identity" {

variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ variable "mysqlserver_settings" {
6767
})
6868
}
6969

70+
variable "create_mode" {
71+
description = "The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`. Defaults to `Default`"
72+
default = "Default"
73+
}
74+
75+
variable "creation_source_server_id" {
76+
description = "For creation modes other than `Default`, the source server ID to use."
77+
default = null
78+
}
79+
80+
variable "restore_point_in_time" {
81+
description = "When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`"
82+
default = null
83+
}
84+
7085
variable "storage_account_name" {
7186
description = "The name of the storage account name"
7287
default = null

0 commit comments

Comments
 (0)