Skip to content

azurermPostgresqlFirewallRule

Manages a Firewall Rule for a PostgreSQL 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 azurermPostgresqlServerExample =
  new azurerm.postgresqlServer.PostgresqlServer(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "example-postgre-server",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "GP_Gen5_2",
    ssl_enforcement_enabled: true,
    version: "11",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPostgresqlServerExample.overrideLogicalId("example");
const azurermPostgresqlFirewallRuleExample =
  new azurerm.postgresqlFirewallRule.PostgresqlFirewallRule(this, "example_2", {
    end_ip_address: "40.112.8.12",
    name: "office",
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermPostgresqlServerExample.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.*/
azurermPostgresqlFirewallRuleExample.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 azurermPostgresqlServerExample =
  new azurerm.postgresqlServer.PostgresqlServer(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 azurermPostgresqlFirewallRuleExample =
  new azurerm.postgresqlFirewallRule.PostgresqlFirewallRule(this, "example_2", {
    end_ip_address: "40.112.255.255",
    name: "office",
    resource_group_name: azurermResourceGroupExample.name,
    server_name: azurermPostgresqlServerExample.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.*/
azurermPostgresqlFirewallRuleExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

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

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

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

  • startIpAddress - (Required) Specifies the Start IP Address associated with this Firewall Rule. Changing this forces a new resource to be created.

  • endIpAddress - (Required) Specifies the End IP Address associated with this Firewall Rule. Changing this forces a new resource to be created.

-> 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 PostgreSQL Firewall Rule.

Timeouts

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

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

Import

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

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