Azure Database PostgreSQL Flexible Server Firewall Rule
This page shows how to write Terraform and Azure Resource Manager for Database PostgreSQL Flexible Server Firewall Rule and write them securely.
azurerm_postgresql_flexible_server_firewall_rule (Terraform)
The PostgreSQL Flexible Server Firewall Rule in Database can be configured in Terraform with the resource name azurerm_postgresql_flexible_server_firewall_rule
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_postgresql_flexible_server_firewall_rule" "example" {
for_each = local.firewall_rules
name = each.key
server_id = azurerm_postgresql_flexible_server.example.id
start_ip_address = each.value["start_ip_address"]
end_ip_address = each.value["end_ip_address"]
resource "azurerm_postgresql_flexible_server_firewall_rule" "example" {
for_each = local.firewall_rules
name = each.key
server_id = azurerm_postgresql_flexible_server.example.id
start_ip_address = each.value["start_ip_address"]
end_ip_address = each.value["end_ip_address"]
resource "azurerm_postgresql_flexible_server_firewall_rule" "this" {
for_each = data.azurerm_public_ip.external_ips
name = local.resource_name
server_id = azurerm_postgresql_flexible_server.this.id
resource "azurerm_postgresql_flexible_server_firewall_rule" "db-firewall-rule" {
name = "db-firewall-rule"
server_id = azurerm_postgresql_flexible_server.broker_database.id
start_ip_address = "10.10.1.0"
end_ip_address = "10.10.1.254"
}
resource "azurerm_postgresql_flexible_server_firewall_rule" "pgsql" {
for_each = toset(var.firewall_rules)
name = replace(each.key, ".", "-")
server_id = azurerm_postgresql_flexible_server.pgsql.id
start_ip_address = each.key
end_ip_address = each.key
Parameters
The following arguments are supported:
name
- (Required) The name which should be used for this PostgreSQL Flexible Server Firewall Rule. Changing this forces a new PostgreSQL Flexible Server Firewall Rule to be created.server_id
- (Required) The ID of the PostgreSQL Flexible Server from which to create this PostgreSQL Flexible Server Firewall Rule. Changing this forces a new PostgreSQL Flexible Server Firewall Rule to be created.start_ip_address
- (Required) The Start IP Address associated with this PostgreSQL Flexible Server Firewall Rule.end_ip_address
- (Required) The End IP Address associated with this PostgreSQL Flexible Server Firewall Rule.
In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the PostgreSQL Flexible Server Firewall Rule.
Explanation in Terraform Registry
Manages a PostgreSQL Flexible Server Firewall Rule.
Tips: Best Practices for The Other Azure Database Resources
In addition to the azurerm_mariadb_firewall_rule, Azure Database has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_mariadb_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_mariadb_server
Ensure that access to Azure SQL Database is restricted
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_mssql_database_extended_auditing_policy
Ensure to configure retention periods of database auditing to enough duration
It is better to configure retention periods of database auditing to enough duration. It would be better to set greater than at least 90 days.
azurerm_mssql_server
Ensure to enable auditing on Azure SQL databases
It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.
azurerm_mssql_server_security_alert_policy
Ensure to configure at least one email address for threat alerts
It is better to configure at least one email address for threat alerts. SQL Server is able to send alerts for threat detection via emails and it could support us to notice the incident on time.
azurerm_mysql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_mysql_server
Ensure to disable public access to database
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_postgresql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_postgresql_server
Ensure to disable public access to database
It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.
azurerm_sql_firewall_rule
Ensure database firewalls do not permit public access
It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.
azurerm_sql_server
Ensure to enable auditing on Azure SQL databases
It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.
Microsoft.DBforPostgreSQL/flexibleServers/firewallRules (Azure Resource Manager)
The flexibleServers/firewallRules in Microsoft.DBforPostgreSQL can be configured in Azure Resource Manager with the resource name Microsoft.DBforPostgreSQL/flexibleServers/firewallRules
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
apiVersion
required - stringname
required - stringThe name of the server firewall rule.
properties
requiredendIpAddress
required - stringThe end IP address of the server firewall rule. Must be IPv4 format.
startIpAddress
required - stringThe start IP address of the server firewall rule. Must be IPv4 format.
type
required - string
Frequently asked questions
What is Azure Database PostgreSQL Flexible Server Firewall Rule?
Azure Database PostgreSQL Flexible Server Firewall Rule is a resource for Database of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Database PostgreSQL Flexible Server Firewall Rule?
For Terraform, the wasfree/azure-support, wasfree/azure-support and nuuday/terraform-k8s-grafana source code examples are useful. See the Terraform Example section for further details.