File tree Expand file tree Collapse file tree 4 files changed +61
-9
lines changed Expand file tree Collapse file tree 4 files changed +61
-9
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ No modules.
35
35
The following resources are used by this module:
36
36
37
37
- [ azurerm_mysql_database.db] ( https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_database ) (resource)
38
+ - [ azurerm_mysql_firewall_rule.firewall] ( https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_firewall_rule ) (resource)
38
39
- [ azurerm_mysql_server.server] ( https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server ) (resource)
39
40
40
41
## Required Inputs
@@ -89,6 +90,22 @@ Type: `string`
89
90
90
91
Default: ` "mysqladmin" `
91
92
93
+ ### allowed\_ ips
94
+
95
+ Description: A hash of permissions to access the database server by ip. The hash key is the name suffix and each value
96
+ has a start and an end value.
97
+
98
+ Type:
99
+
100
+ ``` hcl
101
+ object({
102
+ start = string,
103
+ end = string
104
+ })
105
+ ```
106
+
107
+ Default: ` [] `
108
+
92
109
### backup\_ retention\_ days
93
110
94
111
Description: Number of days to keep backups
@@ -99,15 +116,15 @@ Default: `7`
99
116
100
117
### database\_ host\_ sku
101
118
102
- Description: n/a
119
+ Description: SKU for the database server to use
103
120
104
121
Type: ` string `
105
122
106
- Default: ` "GP_Gen5_1 " `
123
+ Default: ` "GP_Gen5_2 " `
107
124
108
125
### database\_ storage
109
126
110
- Description: n/a
127
+ Description: Required database storage (in MB)
111
128
112
129
Type: ` string `
113
130
@@ -121,6 +138,14 @@ Type: `string`
121
138
122
139
Default: ` "8.0" `
123
140
141
+ ### public\_ access
142
+
143
+ Description: Wether to allow public access to the database server
144
+
145
+ Type: ` bool `
146
+
147
+ Default: ` false `
148
+
124
149
### suffix
125
150
126
151
Description: Naming suffix to allow multiple instances of this module
Original file line number Diff line number Diff line change
1
+ resource "azurerm_mysql_firewall_rule" "firewall" {
2
+ for_each = var. allowed_ips
3
+ start_ip_address = each. value . start
4
+ end_ip_address = each. value . end
5
+ name = " ${ var . project } ${ var . stage } dbfw${ each . key } "
6
+ resource_group_name = var. resource_group
7
+ server_name = azurerm_mysql_server. server . name
8
+ }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ resource "azurerm_mysql_server" "server" {
14
14
backup_retention_days = var. backup_retention_days
15
15
geo_redundant_backup_enabled = false
16
16
infrastructure_encryption_enabled = true
17
- public_network_access_enabled = false
17
+ public_network_access_enabled = var . public_access
18
18
ssl_enforcement_enabled = true
19
19
}
20
20
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ variable "backup_retention_days" {
45
45
}
46
46
}
47
47
48
-
49
48
variable "admin_login" {
50
49
type = string
51
50
description = " Admin login"
@@ -58,11 +57,31 @@ variable "admin_password" {
58
57
}
59
58
60
59
variable "database_host_sku" {
61
- type = string
62
- default = " GP_Gen5_2"
60
+ type = string
61
+ default = " GP_Gen5_2"
62
+ description = " SKU for the database server to use"
63
63
}
64
64
65
65
variable "database_storage" {
66
- type = string
67
- default = " 5120"
66
+ type = string
67
+ default = " 5120"
68
+ description = " Required database storage (in MB)"
69
+ }
70
+
71
+ variable "public_access" {
72
+ description = " Wether to allow public access to the database server"
73
+ type = bool
74
+ default = false
75
+ }
76
+
77
+ variable "allowed_ips" {
78
+ description = << EOF
79
+ A hash of permissions to access the database server by ip. The hash key is the name suffix and each value
80
+ has a start and an end value.
81
+ EOF
82
+ type = object ({
83
+ start = string ,
84
+ end = string
85
+ })
86
+ default = []
68
87
}
You can’t perform that action at this time.
0 commit comments