File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
examples/PostgreSQL_Server Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ module "postgresql-db" {
23
23
admin_username = " postgresadmin"
24
24
admin_password = " H@Sh1CoR3!"
25
25
# Database name, charset and collection arguments
26
- database_name = " demomy -postgres-db"
26
+ database_name = " demo -postgres-db"
27
27
charset = " UTF8"
28
28
collation = " English_United States.1252"
29
29
# Storage Profile and other optional arguments
30
30
auto_grow_enabled = true
31
31
backup_retention_days = 7
32
32
geo_redundant_backup_enabled = true
33
- public_network_access_enabled = false
33
+ public_network_access_enabled = true
34
34
ssl_enforcement_enabled = true
35
35
ssl_minimal_tls_version_enforced = " TLS1_2"
36
36
}
@@ -59,7 +59,7 @@ module "postgresql-db" {
59
59
# (Optional) To enable Azure Monitoring for Azure MySQL database
60
60
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
61
61
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
62
-
62
+ */
63
63
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
64
64
firewall_rules = {
65
65
access-to-azure = {
@@ -71,7 +71,7 @@ module "postgresql-db" {
71
71
end_ip_address = " 49.204.228.223"
72
72
}
73
73
}
74
- */
74
+
75
75
# Tags for Azure Resources
76
76
tags = {
77
77
Terraform = " true"
Original file line number Diff line number Diff line change @@ -133,9 +133,20 @@ resource "azurerm_postgresql_database" "main" {
133
133
# ------------------------------------------------------------
134
134
resource "azurerm_postgresql_configuration" "main" {
135
135
for_each = var. postgresql_configuration != null ? { for k , v in var . postgresql_configuration : k => v if v != null } : {}
136
- name = format ( " %s " , each. key )
136
+ name = each. key
137
137
resource_group_name = local. resource_group_name
138
138
server_name = azurerm_postgresql_server. main . name
139
139
value = each. value
140
140
}
141
141
142
+ # ------------------------------------------------------------
143
+ # Adding Firewall rules for MySQL Server - Default is "false"
144
+ # ------------------------------------------------------------
145
+ resource "azurerm_postgresql_firewall_rule" "main" {
146
+ for_each = var. firewall_rules != null ? { for k , v in var . firewall_rules : k => v if v != null } : {}
147
+ name = format (" %s" , each. key )
148
+ resource_group_name = local. resource_group_name
149
+ server_name = azurerm_postgresql_server. main . name
150
+ start_ip_address = each. value [" start_ip_address" ]
151
+ end_ip_address = each. value [" end_ip_address" ]
152
+ }
Original file line number Diff line number Diff line change @@ -115,6 +115,15 @@ variable "postgresql_configuration" {
115
115
default = {}
116
116
}
117
117
118
+ variable "firewall_rules" {
119
+ description = " Range of IP addresses to allow firewall connections."
120
+ type = map (object ({
121
+ start_ip_address = string
122
+ end_ip_address = string
123
+ }))
124
+ default = null
125
+ }
126
+
118
127
variable "tags" {
119
128
description = " A map of tags to add to all resources"
120
129
type = map (string )
You can’t perform that action at this time.
0 commit comments