Skip to content

azurermMysqlFirewallRule

Manages a Firewall Rule for a MySQL Server.

Example Usage (Single IP Address)

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "api-rg-pro",
  }
);
const azurermMysqlServerExample = new azurerm.mysqlServer.MysqlServer(
  this,
  "example_1",
  {
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "GP_Gen5_2",
    ssl_enforcement_enabled: true,
    version: "5.7",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlServerExample.overrideLogicalId("example");
const azurermMysqlFirewallRuleExample =
  new azurerm.mysqlFirewallRule.MysqlFirewallRule(this, "example_2", {
    end_ip_address: "40.112.8.12",
    name: "office",
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermMysqlServerExample.name,
    start_ip_address: "40.112.8.12",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlFirewallRuleExample.overrideLogicalId("example");

Example Usage (IP Range)

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermMysqlServerExample = new azurerm.mysqlServer.MysqlServer(
  this,
  "example",
  {}
);
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example_1",
  {
    location: "West Europe",
    name: "api-rg-pro",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermResourceGroupExample.overrideLogicalId("example");
const azurermMysqlFirewallRuleExample =
  new azurerm.mysqlFirewallRule.MysqlFirewallRule(this, "example_2", {
    end_ip_address: "40.112.255.255",
    name: "office",
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermMysqlServerExample.name,
    start_ip_address: "40.112.0.0",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlFirewallRuleExample.overrideLogicalId("example");

Example Usage (Allow access to Azure services)

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermMysqlServerExample = new azurerm.mysqlServer.MysqlServer(
  this,
  "example",
  {}
);
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example_1",
  {
    location: "West Europe",
    name: "api-rg-pro",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermResourceGroupExample.overrideLogicalId("example");
const azurermMysqlFirewallRuleExample =
  new azurerm.mysqlFirewallRule.MysqlFirewallRule(this, "example_2", {
    end_ip_address: "0.0.0.0",
    name: "office",
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermMysqlServerExample.name,
    start_ip_address: "0.0.0.0",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlFirewallRuleExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the MySQL Firewall Rule. Changing this forces a new resource to be created.

  • serverName - (Required) Specifies the name of the MySQL Server. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which the MySQL Server exists. Changing this forces a new resource to be created.

  • startIpAddress - (Required) Specifies the Start IP Address associated with this Firewall Rule.

  • endIpAddress - (Required) Specifies the End IP Address associated with this Firewall Rule.

-> NOTE: The Azure feature allowAccessToAzureServices can be enabled by setting startIpAddress and endIpAddress to 0000 which (is documented in the Azure API Docs).

Attributes Reference

The following attributes are exported:

  • id - The ID of the MySQL Firewall Rule.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the MySQL Firewall Rule.
  • update - (Defaults to 30 minutes) Used when updating the MySQL Firewall Rule.
  • read - (Defaults to 5 minutes) Used when retrieving the MySQL Firewall Rule.
  • delete - (Defaults to 30 minutes) Used when deleting the MySQL Firewall Rule.

Import

MySQL Firewall Rule's can be imported using the resourceId, e.g.

terraform import azurerm_mysql_firewall_rule.rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforMySQL/servers/server1/firewallRules/rule1