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.
3535The following resources are used by this module:
3636
3737- [ 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)
3839- [ azurerm_mysql_server.server] ( https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server ) (resource)
3940
4041## Required Inputs
@@ -89,6 +90,22 @@ Type: `string`
8990
9091Default: ` "mysqladmin" `
9192
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+
92109### backup\_ retention\_ days
93110
94111Description: Number of days to keep backups
@@ -99,15 +116,15 @@ Default: `7`
99116
100117### database\_ host\_ sku
101118
102- Description: n/a
119+ Description: SKU for the database server to use
103120
104121Type: ` string `
105122
106- Default: ` "GP_Gen5_1 " `
123+ Default: ` "GP_Gen5_2 " `
107124
108125### database\_ storage
109126
110- Description: n/a
127+ Description: Required database storage (in MB)
111128
112129Type: ` string `
113130
@@ -121,6 +138,14 @@ Type: `string`
121138
122139Default: ` "8.0" `
123140
141+ ### public\_ access
142+
143+ Description: Wether to allow public access to the database server
144+
145+ Type: ` bool `
146+
147+ Default: ` false `
148+
124149### suffix
125150
126151Description: 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" {
1414 backup_retention_days = var. backup_retention_days
1515 geo_redundant_backup_enabled = false
1616 infrastructure_encryption_enabled = true
17- public_network_access_enabled = false
17+ public_network_access_enabled = var . public_access
1818 ssl_enforcement_enabled = true
1919}
2020
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ variable "backup_retention_days" {
4545 }
4646}
4747
48-
4948variable "admin_login" {
5049 type = string
5150 description = " Admin login"
@@ -58,11 +57,31 @@ variable "admin_password" {
5857}
5958
6059variable "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"
6363}
6464
6565variable "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 = []
6887}
You can’t perform that action at this time.
0 commit comments