Azure Database MariaDB Firewall Rule
This page shows how to write Terraform and Azure Resource Manager for Database MariaDB Firewall Rule and write them securely.
azurerm_mariadb_firewall_rule (Terraform)
The MariaDB Firewall Rule in Database can be configured in Terraform with the resource name azurerm_mariadb_firewall_rule
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_mariadb_firewall_rule" "adapt-vilnius" {
name = "adapt-vilnius"
resource_group_name = azurerm_resource_group.rg.name
server_name = azurerm_mariadb_server.man_mariadb.name
start_ip_address = "88.119.96.225"
end_ip_address = "88.119.96.225"
resource "azurerm_mariadb_firewall_rule" "myip" {
name = "personalip"
resource_group_name = azurerm_resource_group.rg.name
server_name = azurerm_mariadb_server.mariaserver.name
start_ip_address = data.http.ip_address.body
end_ip_address = data.http.ip_address.body
resource "azurerm_mariadb_firewall_rule" "mariadb_firewall_rules" {
for_each = try(var.settings.mariadb_firewall_rules, {})
name = each.value.name
resource_group_name = var.resource_group_name
resource "azurerm_mariadb_firewall_rule" "mariadb_firewall_rules" {
for_each = try(var.settings.mariadb_firewall_rules, {})
name = each.value.name
resource_group_name = var.resource_group_name
resource "azurerm_mariadb_firewall_rule" "mariadb_firewall_rules" {
for_each = try(var.settings.mariadb_firewall_rules, {})
name = each.value.name
resource_group_name = var.resource_group_name
resource "azurerm_mariadb_firewall_rule" "example" {
name = var.name
resource_group_name = var.resource_group_name
server_name = var.server_name
start_ip_address = var.start_ip_address
end_ip_address = var.end_ip_address
resource "azurerm_mariadb_firewall_rule" "denied" {
name = "test-rule"
resource_group_name = "test-rg"
server_name = "test-server"
start_ip_address = "0.0.0.0"
end_ip_address = "255.255.255.255"
resource "azurerm_mariadb_firewall_rule" "allowed" {
name = "test-rule"
resource_group_name = "test-rg"
server_name = "test-server"
start_ip_address = "40.112.8.12"
end_ip_address = "40.112.8.12"
resource "azurerm_mariadb_firewall_rule" "mariadb_firewall_rules" {
for_each = try(var.settings.mariadb_firewall_rules, {})
name = each.value.name
resource_group_name = var.resource_group_name
resource "azurerm_mariadb_firewall_rule" "mariadb_fw_rule" {
for_each = var.authorized_cidrs
name = each.key
server_name = azurerm_mariadb_server.mariadb_server.name
resource_group_name = var.resource_group_name
Security Best Practices for azurerm_mariadb_firewall_rule
There is 1 setting in azurerm_mariadb_firewall_rule that should be taken care of for security reasons. The following section explain an overview and example code.
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.
Parameters
-
end_ip_address
required - string -
id
optional computed - string -
name
required - string -
resource_group_name
required - string -
server_name
required - string -
start_ip_address
required - string -
timeouts
single block
Explanation in Terraform Registry
Manages a Firewall Rule for a MariaDB Server
Tips: Best Practices for The Other Azure Database Resources
In addition to the azurerm_mariadb_server, Azure Database has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
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.DBforMariaDB/servers/firewallRules (Azure Resource Manager)
The servers/firewallRules in Microsoft.DBforMariaDB can be configured in Azure Resource Manager with the resource name Microsoft.DBforMariaDB/servers/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 MariaDB Firewall Rule?
Azure Database MariaDB 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 MariaDB Firewall Rule?
For Terraform, the Rsimk/mancom-v2, higorbarbosa/treinamento-terraform-azure and aztfmod/terraform-azurerm-caf source code examples are useful. See the Terraform Example section for further details.