Skip to content

Commit c8cd09a

Browse files
authored
Merge branch 'master' into fix/version-upgrade
2 parents 66fd2e8 + 5f169f1 commit c8cd09a

File tree

5 files changed

+97
-13
lines changed

5 files changed

+97
-13
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.0.2] - 2024-10-29
8+
### :sparkles: New Features
9+
- [`82e81ea`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/82e81ea77b10b1779c8223773727a564417b25a4) - Added diagnostic settings *(commit by [@13archit](https://github.com/13archit))*
10+
11+
### :bug: Bug Fixes
12+
- [`34d3b5b`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/34d3b5bc24885be9d4bf692cc7b07718a4790560) - renamed _examples to examples and referenced it *(commit by [@vjdbj](https://github.com/vjdbj))*
13+
- [`706034d`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/706034dc905e57ce474e649bc4c146c0d38ca59a) - added versions in examples *(commit by [@vjdbj](https://github.com/vjdbj))*
14+
- [`96ad328`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/96ad3284773f4e8da8ced82e3875e36b3b21e6d2) - fixed versions in examples *(commit by [@vjdbj](https://github.com/vjdbj))*
15+
- [`9c39dad`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/9c39dad158dc968e1b9295154f926c31d2a81d28) - fixed tf version *(commit by [@vjdbj](https://github.com/vjdbj))*
16+
17+
### :construction_worker: Build System
18+
- [`adc6d6c`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/adc6d6c7effd447a7f0650dfa5eb22c182e90382) - **deps**: bump clouddrove/subnet/azure in /_example/complete *(commit by [@dependabot[bot]](https://github.com/apps/dependabot))*
19+
- [`34215d5`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/34215d5ce62fa8c870c05c96f63c09aa5cd16802) - **deps**: bump clouddrove/subnet/azure *(commit by [@dependabot[bot]](https://github.com/apps/dependabot))*
20+
21+
722
## [1.0.1] - 2023-07-03
823
### :sparkles: New Features
924
- [`c690aa3`](https://github.com/clouddrove/terraform-azure-flexible-mysql/commit/c690aa3ad0b3ae5d324c3820097e27cbaf7eb522) - auto changelog action added *(commit by [@themaheshyadav](https://github.com/themaheshyadav))*
@@ -27,3 +42,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2742
[1.0.0]: https://github.com/clouddrove/terraform-azure-flexible-mysql/compare/1.0.0...master
2843

2944
[1.0.1]: https://github.com/clouddrove/terraform-azure-flexible-mysql/compare/1.0.0...1.0.1
45+
46+
[1.0.2]: https://github.com/clouddrove/terraform-azure-flexible-mysql/compare/1.0.1...1.0.2
47+

docs/io.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@
1010
| charset | Specifies the Charset for the MySQL Database, which needs to be a valid MySQL Charset. Changing this forces a new resource to be created. | `string` | `""` | no |
1111
| collation | Specifies the Collation for the MySQL Database, which needs to be a valid MySQL Collation. Changing this forces a new resource to be created. | `string` | `""` | no |
1212
| create\_mode | The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`. Defaults to `Default` | `string` | `"Default"` | no |
13+
| custom\_tags | n/a | `map(string)` | `{}` | no |
1314
| db\_name | Specifies the name of the MySQL Database, which needs to be a valid MySQL identifier. Changing this forces a new resource to be created. | `string` | `""` | no |
1415
| delegated\_subnet\_id | The resource ID of the subnet | `string` | `""` | no |
1516
| enable\_diagnostic | Set to false to prevent the module from creating any resources. | `bool` | `true` | no |
1617
| enable\_private\_endpoint | Manages a Private Endpoint to Azure database for MySQL | `bool` | `false` | no |
1718
| enabled | Set to false to prevent the module from creating any resources. | `bool` | `true` | no |
1819
| end\_ip\_address | n/a | `string` | `""` | no |
20+
| entra\_authentication | Azure Entra authentication configuration block for Azure MySQL Flexible Server | <pre>object({<br> user_assigned_identity_id = optional(string, null)<br> login = optional(string, null)<br> object_id = optional(string, null)<br> })</pre> | `{}` | no |
1921
| environment | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `""` | no |
2022
| eventhub\_authorization\_rule\_id | Eventhub authorization rule id to pass it to destination details of diagnosys setting of NSG. | `string` | `null` | no |
2123
| eventhub\_name | Eventhub Name to pass it to destination details of diagnosys setting of NSG. | `string` | `null` | no |
2224
| existing\_private\_dns\_zone | Name of the existing private DNS zone | `bool` | `false` | no |
2325
| existing\_private\_dns\_zone\_id | n/a | `string` | `""` | no |
2426
| existing\_private\_dns\_zone\_name | The name of the Private DNS zone (without a terminating dot). Changing this forces a new resource to be created. | `string` | `""` | no |
2527
| geo\_redundant\_backup\_enabled | Should geo redundant backup enabled? Defaults to false. Changing this forces a new MySQL Flexible Server to be created. | `bool` | `true` | no |
26-
| high\_availability | Map of high availability configuration: https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-high-availability. `null` to disable high availability | <pre>object({<br> mode = string<br> standby_availability_zone = optional(number)<br> })</pre> | <pre>{<br> "mode": "SameZone",<br> "standby_availability_zone": 1<br>}</pre> | no |
28+
| high\_availability | Map of high availability configuration: https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-high-availability. `null` to disable high availability | <pre>object({<br> mode = string<br> standby_availability_zone = optional(number)<br> })</pre> | `null` | no |
29+
| identity\_type | Type of managed identity to set | `string` | `null` | no |
2730
| iops | The storage IOPS for the MySQL Flexible Server. Possible values are between 360 and 20000. | `number` | `360` | no |
2831
| key\_vault\_id | Specifies the URL to a Key Vault Key (either from a Key Vault Key, or the Key URL for the Key Vault Secret | `string` | `""` | no |
2932
| key\_vault\_key\_id | The URL to a Key Vault Key | `string` | `null` | no |
@@ -50,6 +53,7 @@
5053
| source\_server\_id | The resource ID of the source MySQL Flexible Server to be restored. Required when create\_mode is PointInTimeRestore, GeoRestore, and Replica. Changing this forces a new MySQL Flexible Server to be created. | `string` | `null` | no |
5154
| start\_ip\_address | n/a | `string` | `""` | no |
5255
| storage\_account\_id | Storage account id to pass it to destination details of diagnosys setting of NSG. | `string` | `null` | no |
56+
| user\_assigned\_identity\_ids | List of user-assigned managed identity IDs | `list(string)` | `[]` | no |
5357
| values | Specifies the value of the MySQL Flexible Server Configuration. See the MySQL documentation for valid values. Changing this forces a new resource to be created. | `list(string)` | `[]` | no |
5458
| virtual\_network\_id | The name of the virtual network | `string` | `""` | no |
5559
| zone | Specifies the Availability Zone in which this MySQL Flexible Server should be located. Possible values are 1, 2 and 3. | `number` | `null` | no |
@@ -63,3 +67,6 @@
6367
| azurerm\_private\_dns\_zone\_virtual\_network\_link\_id | The ID of the Private DNS Zone Virtual Network Link. |
6468
| existing\_private\_dns\_zone\_virtual\_network\_link\_id | The ID of the Private DNS Zone Virtual Network Link. |
6569
| mysql\_flexible\_server\_id | The ID of the MySQL Flexible Server. |
70+
71+
| password\_result | Password Value |
72+

main.tf

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ resource "random_password" "main" {
4242

4343
resource "azurerm_mysql_flexible_server" "main" {
4444
count = var.enabled ? 1 : 0
45-
name = format("%s-mysql-flexible-server", module.labels.id)
45+
name = var.mysql_server_name != null ? var.mysql_server_name : format("%s-mysql-flexible-server", module.labels.id)
4646
resource_group_name = local.resource_group_name
4747
location = var.location
4848
administrator_login = var.admin_username
@@ -69,6 +69,14 @@ resource "azurerm_mysql_flexible_server" "main" {
6969
standby_availability_zone = lookup(high_availability.value, "standby_availability_zone", 1)
7070
}
7171
}
72+
dynamic "identity" {
73+
for_each = toset(var.identity_type != null ? [var.identity_type] : [])
74+
content {
75+
type = var.identity_type
76+
identity_ids = var.identity_type == "UserAssigned" ? var.user_assigned_identity_ids : []
77+
}
78+
79+
}
7280

7381
dynamic "identity" {
7482
for_each = var.cmk_enabled ? [true] : []
@@ -94,13 +102,33 @@ resource "azurerm_mysql_flexible_server" "main" {
94102
version = var.mysql_version
95103
zone = var.zone
96104

97-
tags = module.labels.tags
105+
tags = var.custom_tags == null ? module.labels.tags : var.custom_tags
98106

99107
depends_on = [azurerm_private_dns_zone_virtual_network_link.main, azurerm_private_dns_zone_virtual_network_link.main2]
100108
}
101109

102110
##-----------------------------------------------------------------------------
103111
## Below resource will create mysql flexible database.
112+
113+
##-----------------------------------------------------------------------------
114+
## Below resource will create mysql server active directory administrator.
115+
##-----------------------------------------------------------------------------
116+
117+
resource "azurerm_mysql_flexible_server_active_directory_administrator" "main" {
118+
count = length(var.entra_authentication.object_id[*]) > 0 ? 1 : 0
119+
120+
server_id = join("", azurerm_mysql_flexible_server.main.*.id)
121+
identity_id = var.entra_authentication.user_assigned_identity_id
122+
login = var.entra_authentication.login
123+
object_id = var.entra_authentication.object_id
124+
tenant_id = data.azurerm_client_config.current.tenant_id
125+
126+
depends_on = [azurerm_mysql_flexible_server.main]
127+
}
128+
129+
##-----------------------------------------------------------------------------
130+
## Below resource will create mysql flexible database.
131+
104132
##-----------------------------------------------------------------------------
105133

106134
resource "azurerm_mysql_flexible_database" "main" {
@@ -110,7 +138,7 @@ resource "azurerm_mysql_flexible_database" "main" {
110138
server_name = azurerm_mysql_flexible_server.main[0].name
111139
charset = var.charset
112140
collation = var.collation
113-
depends_on = [azurerm_mysql_flexible_server.main]
141+
depends_on = [azurerm_mysql_flexible_server_active_directory_administrator.main]
114142
}
115143

116144
##-----------------------------------------------------------------------------
@@ -132,7 +160,7 @@ resource "azurerm_private_dns_zone" "main" {
132160
count = var.enabled && var.private_dns ? 1 : 0
133161
name = "privatelink.mysql.database.azure.com"
134162
resource_group_name = local.resource_group_name
135-
tags = module.labels.tags
163+
tags = var.custom_tags == null ? module.labels.tags : var.custom_tags
136164
}
137165

138166
##-----------------------------------------------------------------------------
@@ -145,7 +173,7 @@ resource "azurerm_private_dns_zone_virtual_network_link" "main" {
145173
virtual_network_id = var.virtual_network_id
146174
resource_group_name = local.resource_group_name
147175
registration_enabled = var.registration_enabled
148-
tags = module.labels.tags
176+
tags = var.custom_tags == null ? module.labels.tags : var.custom_tags
149177
}
150178

151179
##-----------------------------------------------------------------------------
@@ -158,7 +186,7 @@ resource "azurerm_private_dns_zone_virtual_network_link" "main2" {
158186
virtual_network_id = var.virtual_network_id
159187
resource_group_name = var.main_rg_name
160188
registration_enabled = var.registration_enabled
161-
tags = module.labels.tags
189+
tags = var.custom_tags == null ? module.labels.tags : var.custom_tags
162190
}
163191

164192
resource "azurerm_monitor_diagnostic_setting" "mysql" {

output.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ output "azurerm_private_dns_zone_virtual_network_link_id" {
77
value = azurerm_private_dns_zone_virtual_network_link.main[0].id
88
description = "The ID of the Private DNS Zone Virtual Network Link."
99
}
10+
1011
output "existing_private_dns_zone_virtual_network_link_id" {
1112
value = length(azurerm_private_dns_zone_virtual_network_link.main2) > 0 ? azurerm_private_dns_zone_virtual_network_link.main2[0].id : null
1213
}
14+
1315
output "azurerm_mysql_flexible_server_configuration_id" {
1416
value = azurerm_mysql_flexible_server_configuration.main[0].id
1517
description = "The ID of the MySQL Flexible Server Configuration."
1618
}
19+
1720
output "azurerm_private_dns_zone_id" {
1821
value = azurerm_private_dns_zone.main[0].id
1922
description = "The Private DNS Zone ID."
2023
}
24+
25+
output "password_result" {
26+
value = var.admin_password == null ? random_password.main[0].result : var.admin_password
27+
description = "Password Value"
28+
sensitive = true
29+
}

variables.tf

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ variable "resource_group_name" {
3636
default = ""
3737
}
3838

39-
40-
4139
variable "enabled" {
4240
type = bool
4341
description = "Set to false to prevent the module from creating any resources."
@@ -215,10 +213,7 @@ variable "high_availability" {
215213
mode = string
216214
standby_availability_zone = optional(number)
217215
})
218-
default = {
219-
mode = "SameZone"
220-
standby_availability_zone = 1
221-
}
216+
default = null
222217
}
223218

224219
variable "enable_diagnostic" {
@@ -294,3 +289,30 @@ variable "key_vault_with_rbac" {
294289
type = bool
295290
default = false
296291
}
292+
293+
variable "custom_tags" {
294+
type = map(string)
295+
default = {}
296+
}
297+
298+
variable "identity_type" {
299+
description = "Type of managed identity to set"
300+
type = string
301+
default = null
302+
}
303+
304+
variable "user_assigned_identity_ids" {
305+
description = "List of user-assigned managed identity IDs"
306+
type = list(string)
307+
default = []
308+
}
309+
310+
variable "entra_authentication" {
311+
description = "Azure Entra authentication configuration block for Azure MySQL Flexible Server"
312+
type = object({
313+
user_assigned_identity_id = optional(string, null)
314+
login = optional(string, null)
315+
object_id = optional(string, null)
316+
})
317+
default = {}
318+
}

0 commit comments

Comments
 (0)