Skip to content

Commit bdf776c

Browse files
authored
Merge pull request #1 from kumarvna/develop
Initial version 1.0
2 parents 54ea0c4 + a6833b2 commit bdf776c

File tree

9 files changed

+826
-1
lines changed

9 files changed

+826
-1
lines changed

README.md

Lines changed: 239 additions & 1 deletion
Large diffs are not rendered by default.

example/complete/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 create a resource group
13+
# proivde a name to use an existing resource group and set the argument
14+
# to `create_resource_group = false` if you want to existing resoruce group.
15+
# If you use existing resrouce group location will be the same as existing RG.
16+
create_resource_group = false
17+
resource_group_name = "rg-shared-westeurope-01"
18+
location = "westeurope"
19+
20+
# MySQL Server and Database settings
21+
mysqlserver_name = "roshmysqldbsrv01"
22+
23+
mysqlserver_settings = {
24+
sku_name = "GP_Gen5_16"
25+
storage_mb = 5120
26+
version = "5.7"
27+
# Database name, charset and collection arguments
28+
database_name = "roshydemomysqldb"
29+
charset = "utf8"
30+
collation = "utf8_unicode_ci"
31+
# Storage Profile and other optional arguments
32+
auto_grow_enabled = true
33+
backup_retention_days = 7
34+
geo_redundant_backup_enabled = false
35+
infrastructure_encryption_enabled = false
36+
public_network_access_enabled = true
37+
ssl_enforcement_enabled = true
38+
ssl_minimal_tls_version_enforced = "TLS1_2"
39+
}
40+
41+
# MySQL Server Parameters
42+
# For more information: https://docs.microsoft.com/en-us/azure/mysql/concepts-server-parameters
43+
mysql_configuration = {
44+
interactive_timeout = "600"
45+
}
46+
47+
# Use Virtual Network service endpoints and rules for Azure Database for MySQL
48+
subnet_id = var.subnet_id
49+
50+
# The URL to a Key Vault custom managed key
51+
key_vault_key_id = var.key_vault_key_id
52+
53+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
54+
enable_threat_detection_policy = true
55+
log_retention_days = 30
56+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
57+
58+
# AD administrator for an Azure MySQL server
59+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
60+
ad_admin_login_name = "[email protected]"
61+
62+
# (Optional) To enable Azure Monitoring for Azure MySQL database
63+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
64+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
65+
66+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
67+
firewall_rules = {
68+
access-to-azure = {
69+
start_ip_address = "0.0.0.0"
70+
end_ip_address = "0.0.0.0"
71+
},
72+
desktop-ip = {
73+
start_ip_address = "49.204.228.223"
74+
end_ip_address = "49.204.228.223"
75+
}
76+
}
77+
78+
# Tags for Azure Resources
79+
tags = {
80+
Terraform = "true"
81+
Environment = "dev"
82+
Owner = "test-user"
83+
}
84+
}
85+
```
86+
87+
## Terraform Usage
88+
89+
To run this example you need to execute following Terraform commands
90+
91+
```hcl
92+
terraform init
93+
94+
terraform plan
95+
96+
terraform apply
97+
```
98+
99+
Run `terraform destroy` when you don't need these resources.

example/complete/main.tf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module "mssql-server" {
2+
source = "kumarvna/mysql-db/azurerm"
3+
version = "1.0.0"
4+
5+
# By default, this module will create a resource group
6+
# proivde a name to use an existing resource group and set the argument
7+
# to `create_resource_group = false` if you want to existing resoruce group.
8+
# If you use existing resrouce group location will be the same as existing RG.
9+
create_resource_group = false
10+
resource_group_name = "rg-shared-westeurope-01"
11+
location = "westeurope"
12+
13+
# MySQL Server and Database settings
14+
mysqlserver_name = "roshmysqldbsrv01"
15+
16+
mysqlserver_settings = {
17+
sku_name = "GP_Gen5_16"
18+
storage_mb = 5120
19+
version = "5.7"
20+
# Database name, charset and collection arguments
21+
database_name = "roshydemomysqldb"
22+
charset = "utf8"
23+
collation = "utf8_unicode_ci"
24+
# Storage Profile and other optional arguments
25+
auto_grow_enabled = true
26+
backup_retention_days = 7
27+
geo_redundant_backup_enabled = false
28+
infrastructure_encryption_enabled = false
29+
public_network_access_enabled = true
30+
ssl_enforcement_enabled = true
31+
ssl_minimal_tls_version_enforced = "TLS1_2"
32+
}
33+
34+
# MySQL Server Parameters
35+
# For more information: https://docs.microsoft.com/en-us/azure/mysql/concepts-server-parameters
36+
mysql_configuration = {
37+
interactive_timeout = "600"
38+
}
39+
40+
# Use Virtual Network service endpoints and rules for Azure Database for MySQL
41+
subnet_id = var.subnet_id
42+
43+
# The URL to a Key Vault custom managed key
44+
key_vault_key_id = var.key_vault_key_id
45+
46+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
47+
enable_threat_detection_policy = true
48+
log_retention_days = 30
49+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
50+
51+
# AD administrator for an Azure MySQL server
52+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
53+
ad_admin_login_name = "[email protected]"
54+
55+
# (Optional) To enable Azure Monitoring for Azure MySQL database
56+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
57+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
58+
59+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
60+
firewall_rules = {
61+
access-to-azure = {
62+
start_ip_address = "0.0.0.0"
63+
end_ip_address = "0.0.0.0"
64+
},
65+
desktop-ip = {
66+
start_ip_address = "49.204.228.223"
67+
end_ip_address = "49.204.228.223"
68+
}
69+
}
70+
71+
# Tags for Azure Resources
72+
tags = {
73+
Terraform = "true"
74+
Environment = "dev"
75+
Owner = "test-user"
76+
}
77+
}

example/complete/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "key_vault_key_id" {
2+
description = "The URL to a Key Vault Key"
3+
default = null
4+
}
5+
6+
variable "subnet_id" {
7+
description = "The resource ID of the subnet"
8+
default = null
9+
}

graph.png

328 KB
Loading

0 commit comments

Comments
 (0)