Skip to content

Commit 2e9c33d

Browse files
authored
Merge pull request #2 from kumarvna/develop
final configuration for version 1.1.0
2 parents bdf776c + 146ed8e commit 2e9c33d

File tree

12 files changed

+554
-18
lines changed

12 files changed

+554
-18
lines changed

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ Azure Database for MySQL is easy to set up, manage and scale. It automates the
1212
* [MySQL Customer Managed Key](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server_key)
1313
* [MySQL Virtual Network Rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_virtual_network_rule)
1414
* [MySQL Diagnostics](https://docs.microsoft.com/en-us/azure/azure-sql/database/metrics-diagnostic-telemetry-logging-streaming-export-configure?tabs=azure-portal)
15+
* [Private Endpoints](https://www.terraform.io/docs/providers/azurerm/r/private_endpoint.html)
16+
* [Private DNS zone for `privatelink` A records](https://www.terraform.io/docs/providers/azurerm/r/private_dns_zone.html)
1517

1618
## Module Usage
1719

1820
```hcl
19-
module "mssql-server" {
21+
module "mysql-db" {
2022
source = "kumarvna/mysql-db/azurerm"
21-
version = "1.0.0"
23+
version = "1.1.0"
2224
2325
# By default, this module will create a resource group
2426
# proivde a name to use an existing resource group and set the argument
@@ -29,14 +31,14 @@ module "mssql-server" {
2931
location = "westeurope"
3032
3133
# MySQL Server and Database settings
32-
mysqlserver_name = "roshmysqldbsrv01"
34+
mysqlserver_name = "mysqldbsrv01"
3335
3436
mysqlserver_settings = {
3537
sku_name = "GP_Gen5_16"
3638
storage_mb = 5120
3739
version = "5.7"
3840
# Database name, charset and collection arguments
39-
database_name = "roshydemomysqldb"
41+
database_name = "demomysqldb"
4042
charset = "utf8"
4143
collation = "utf8_unicode_ci"
4244
# Storage Profile and other optional arguments
@@ -61,6 +63,14 @@ module "mssql-server" {
6163
# The URL to a Key Vault custom managed key
6264
key_vault_key_id = var.key_vault_key_id
6365
66+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
67+
# By default this will create a `privatelink.mysql.database.azure.com` DNS zone.
68+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
69+
enable_private_endpoint = true
70+
virtual_network_name = "vnet-shared-hub-westeurope-001"
71+
private_subnet_address_prefix = ["10.1.5.0/29"]
72+
# existing_private_dns_zone = "demo.example.com"
73+
6474
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
6575
enable_threat_detection_policy = true
6676
log_retention_days = 30
@@ -138,6 +148,8 @@ A few Supported parameters are here for your reference. you can find all these `
138148

139149
A virtual network rule for your Azure Database for MySQL server is a subnet that is listed in the access control list (ACL) of your Azure Database for MySQL server. To be in the ACL for your Azure Database for MySQL server, the subnet must contain the **`Microsoft.Sql`** type name. To enable this feature, add a `subnet_id` with valid resource id.
140150

151+
>This feature is available in all regions of Azure where Azure Database for MySQL is deployed for General Purpose and Memory Optimized servers. In case of VNet peering, if traffic is flowing through a common VNet Gateway with service endpoints and is supposed to flow to the peer, please create an ACL/VNet rule to allow Azure Virtual Machines in the Gateway VNet to access the Azure Database for MySQL server.
152+
141153
### Data Encryption with a Customer-managed Key
142154

143155
Data encryption with customer-managed keys for Azure Database for MySQL enables you to bring your own key (BYOK) for data protection at rest. It also allows organizations to implement separation of duties in the management of keys and data.
@@ -146,13 +158,17 @@ Data encryption is set at the server-level. The customer-managed key is an asymm
146158

147159
### Server Firewall Rules
148160

149-
Firewalls prevent all access to your database server until you specify which computers have permission. To configure a firewall, create firewall rules that specify ranges of acceptable IP addresses. You can create firewall rules at the server level with variable `firewall_rules` with valid IP addresses.
161+
Firewalls prevent all access to your database server until you specify which computers have permission. To configure a firewall, create firewall rules that specify ranges of acceptable IP addresses.
162+
163+
By default, no external access to your MySQL Database will be allowed until you explicitly assign permission by creating a firewall rule. To add the firewall rules to the MySQL database, specify the list of `firewall_rules` with valid IP addresses.
150164

151-
### Active Directory Administrator
165+
### Adding Active Directory Administrator to SQL Database
152166

153-
This module supports for Azure Active Directory (Azure AD) integration for Azure Database for MySQL. This integration allows you to securely sign in to their database by using Azure Active Directory and to manage credentials in a central place. For consistent role management, manage database access using Active Directory groups. You can add AD user/group using `ad_admin_login_name` variable.
167+
Azure Active Directory authentication is a mechanism of connecting to Microsoft Azure database for MySQL by using identities in Azure Active Directory (Azure AD). This module adds the provided Azure Active Directory user/group to MySQL Database as an administrator so that the user can login to this database with Azure AD authentication.
154168

155-
> Azure Active Directory authentication is only available for MySQL 5.7 and newer. Only one Azure AD administrator can be configured for a Azure Database for MySQL server at any time. Only an Azure AD administrator for MySQL can initially connect to the Azure Database for MySQL using an Azure Active Directory account.
169+
By default, this feature not enabled on this module. To add the Active Directory Administrator, set the argument `ad_admin_login_name` with a valid Azure AD user/group login name.
170+
171+
>Azure Active Directory authentication is only available for MySQL 5.7 and newer. Only one Azure AD administrator can be configured for a Azure Database for MySQL server at any time. Only an Azure AD administrator for MySQL can initially connect to the Azure Database for MySQL using an Azure Active Directory account.
156172
157173
### Threat detection policy AKA Server Security Alerts Policy
158174

@@ -164,14 +180,30 @@ Advanced Threat Detection for Azure Database for MySQL server detects anomalous
164180
* Access from a potentially harmful application
165181
* Brute force login credentials
166182

167-
Enable threat detection policy setting up the variables `enable_threat_detection_policy`, `log_retention_days` and `email_addresses_for_alerts` with valid values.
183+
By default, this feature not enabled on this module. Enable threat detection policy setting up the variables `enable_threat_detection_policy`, `log_retention_days` and `email_addresses_for_alerts` with valid values.
184+
185+
>Note: Enabling `threat_detection_policy` features on SQL servers and database going to create a storage account to keep all audit logs. Log retention policy to be configured to keep the size within limits for this storage account. Note that this module creates resources that can cost money.
186+
187+
### Private Link to Azure Database for MySQL
188+
189+
Azure Private Endpoint is a network interface that connects you privately and securely to a service powered by Azure Private Link. Private Endpoint uses a private IP address from your VNet, effectively bringing the service into your VNet.
190+
191+
With Private Link, Microsoft offering the ability to associate a logical server to a specific private IP address (also known as private endpoint) within the VNet. This module helps to implement Failover Groups using private endpoint for SQL Database instead of the public endpoint thus ensuring that customers can get security benefits that it offers.
192+
193+
Clients can connect to the Private endpoint from the same VNet, peered VNet in same region, or via VNet-to-VNet connection across regions. Additionally, clients can connect from on-premises using ExpressRoute, private peering, or VPN tunneling.
194+
195+
By default, this feature not enabled on this module. To create private link with private endpoints set the variable `enable_private_endpoint` to `true` and provide `virtual_network_name`, `private_subnet_address_prefix` with a valid values. You can also use the existing private DNS zone to create DNS records. To use this feature, set the `existing_private_dns_zone` with a valid existing private DNS zone name.
196+
197+
For more details: [Private Link for Azure Database for MySQL](https://docs.microsoft.com/en-us/azure/mysql/concepts-data-access-security-private-link)
198+
199+
>The private link feature is only available for Azure Database for MySQL servers in the General Purpose or Memory Optimized pricing tiers. Ensure the database server is in one of these pricing tiers.
168200
169201
## Recommended naming and tagging conventions
170202

171203
Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production.
172204
For recommendations on how to implement a tagging strategy, see Resource naming and tagging decision guide.
173205

174-
> **Important** :
206+
>**Important** :
175207
Tag names are case-insensitive for operations. A tag with a tag name, regardless of the casing, is updated or retrieved. However, the resource provider might keep the casing you provide for the tag name. You'll see that casing in cost reports. **Tag values are case-sensitive.**
176208

177209
An effective naming convention assembles resource names by using important resource information as parts of a resource's name. For example, using these [recommended naming conventions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging#example-names), a public IP resource for a production SharePoint workload is named like this: `pip-sharepoint-prod-westus-001`.
@@ -215,6 +247,10 @@ firewall_rules|Range of IP addresses to allow firewall connections|map(object({}
215247
`ad_admin_login_name`|The login name of the principal to set as the server administrator|string|`null`
216248
`key_vault_key_id`|The URL to a Key Vault custom managed key|string|`null`
217249
`extaudit_diag_logs`|Database Monitoring Category details for Azure Diagnostic setting|list(string)|`["MySqlSlowLogs", "MySqlAuditLogs"]`
250+
`enable_private_endpoint`|Azure Private Endpoint is a network interface that connects you privately and securely to a service powered by Azure Private Link|string|`"false"`
251+
`virtual_network_name` | The name of the virtual network|string|`""`
252+
`private_subnet_address_prefix`|A list of subnets address prefixes inside virtual network| list |`[]`
253+
`existing_private_dns_zone`|Name of the existing private DNS zone|string|`null`
218254
`Tags` | A map of tags to add to all resources | map | `{}`
219255

220256
## Outputs
@@ -224,6 +260,10 @@ firewall_rules|Range of IP addresses to allow firewall connections|map(object({}
224260
`mysql_server_id`|The resource ID of the MySQL Server
225261
`mysql_server_fqdn`|The FQDN of the MySQL Server
226262
`mysql_database_id`|The resource ID of the MySQL Database
263+
`mysql_server_private_endpoint`|id of the MySQL server Private Endpoint
264+
`mysql_server_private_dns_zone_domain`|DNS zone name of MySQL server Private endpoints DNS name records
265+
`mysql_server_private_endpoint_ip`|MySQL server private endpoint IPv4 Addresses
266+
`mysql_server_private_endpoint_fqdn`|MySQL server private endpoint FQDN Addresses
227267

228268
## Resource Graph
229269

example/complete/README.md renamed to examples/MySQL_Server/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Azure Database for MySQL is easy to set up, manage and scale. It automates the
55
## Module Usage
66

77
```hcl
8-
module "mssql-server" {
8+
module "mysql-db" {
99
source = "kumarvna/mysql-db/azurerm"
10-
version = "1.0.0"
10+
version = "1.1.0"
1111
1212
# By default, this module will create a resource group
1313
# proivde a name to use an existing resource group and set the argument
@@ -18,14 +18,14 @@ module "mssql-server" {
1818
location = "westeurope"
1919
2020
# MySQL Server and Database settings
21-
mysqlserver_name = "roshmysqldbsrv01"
21+
mysqlserver_name = "mysqldbsrv01"
2222
2323
mysqlserver_settings = {
2424
sku_name = "GP_Gen5_16"
2525
storage_mb = 5120
2626
version = "5.7"
2727
# Database name, charset and collection arguments
28-
database_name = "roshydemomysqldb"
28+
database_name = "demomysqldb"
2929
charset = "utf8"
3030
collation = "utf8_unicode_ci"
3131
# Storage Profile and other optional arguments

example/complete/main.tf renamed to examples/MySQL_Server/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module "mssql-server" {
1+
module "mysql-db" {
22
source = "kumarvna/mysql-db/azurerm"
3-
version = "1.0.0"
3+
version = "1.1.0"
44

55
# By default, this module will create a resource group
66
# proivde a name to use an existing resource group and set the argument
@@ -11,14 +11,14 @@ module "mssql-server" {
1111
location = "westeurope"
1212

1313
# MySQL Server and Database settings
14-
mysqlserver_name = "roshmysqldbsrv01"
14+
mysqlserver_name = "mysqldbsrv01"
1515

1616
mysqlserver_settings = {
1717
sku_name = "GP_Gen5_16"
1818
storage_mb = 5120
1919
version = "5.7"
2020
# Database name, charset and collection arguments
21-
database_name = "roshydemomysqldb"
21+
database_name = "demomysqldb"
2222
charset = "utf8"
2323
collation = "utf8_unicode_ci"
2424
# Storage Profile and other optional arguments
File renamed without changes.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 "mysql-db" {
9+
source = "kumarvna/mysql-db/azurerm"
10+
version = "1.1.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 = "mysqldbsrv01"
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 = "demomysqldb"
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+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
54+
# By default this will create a `privatelink.mysql.database.azure.com` DNS zone.
55+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
56+
enable_private_endpoint = true
57+
virtual_network_name = "vnet-shared-hub-westeurope-001"
58+
private_subnet_address_prefix = ["10.1.5.0/29"]
59+
# existing_private_dns_zone = "demo.example.com"
60+
61+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
62+
enable_threat_detection_policy = true
63+
log_retention_days = 30
64+
email_addresses_for_alerts = ["user@example.com", "firstname.lastname@example.com"]
65+
66+
# AD administrator for an Azure MySQL server
67+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
68+
ad_admin_login_name = "firstname.lastname@example.com"
69+
70+
# (Optional) To enable Azure Monitoring for Azure MySQL database
71+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
72+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
73+
74+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
75+
firewall_rules = {
76+
access-to-azure = {
77+
start_ip_address = "0.0.0.0"
78+
end_ip_address = "0.0.0.0"
79+
},
80+
desktop-ip = {
81+
start_ip_address = "49.204.228.223"
82+
end_ip_address = "49.204.228.223"
83+
}
84+
}
85+
86+
# Tags for Azure Resources
87+
tags = {
88+
Terraform = "true"
89+
Environment = "dev"
90+
Owner = "test-user"
91+
}
92+
}
93+
```
94+
95+
## Terraform Usage
96+
97+
To run this example you need to execute following Terraform commands
98+
99+
```hcl
100+
terraform init
101+
102+
terraform plan
103+
104+
terraform apply
105+
```
106+
107+
Run `terraform destroy` when you don't need these resources.

0 commit comments

Comments
 (0)