» azurerm_postgresql_virtual_network_rule
Manages a PostgreSQL Virtual Network Rule.
NOTE: PostgreSQL Virtual Network Rules can only be used with SKU Tiers of GeneralPurpose
or MemoryOptimized
» Example Usage
resource "azurerm_resource_group" "test" {
name = "example-resources"
location = "West US"
}
resource "azurerm_virtual_network" "test" {
name = "example-vnet"
address_space = ["10.7.29.0/29"]
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.7.29.0/29"
service_endpoints = ["Microsoft.Sql"]
}
resource "azurerm_postgresql_server" "test" {
name = "postgresql-server-1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "GP_Gen5_2"
capacity = 2
tier = "GeneralPurpose"
family = "Gen5"
}
storage_profile {
storage_mb = 5120
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}
administrator_login = "psqladminun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.5"
ssl_enforcement = "Enabled"
}
resource "azurerm_postgresql_virtual_network_rule" "test" {
name = "postgresql-vnet-rule"
resource_group_name = "${azurerm_resource_group.test.name}"
server_name = "${azurerm_postgresql_server.test.name}"
subnet_id = "${azurerm_subnet.internal.id}"
ignore_missing_vnet_service_endpoint = true
}
» Argument Reference
The following arguments are supported:
-
name
- (Required) The name of the PostgreSQL virtual network rule. Cannot be empty and must only contain alphanumeric characters and hyphens. Cannot start with a number, and cannot start or end with a hyphen. Changing this forces a new resource to be created.
NOTE: name
must be between 1-128 characters long and must satisfy all of the requirements below:
1. Contains only alphanumeric and hyphen characters
2. Cannot start with a number or hyphen
3. Cannot end with a hyphen
-
resource_group_name
- (Required) The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created. -
server_name
- (Required) The name of the SQL Server to which this PostgreSQL virtual network rule will be applied to. Changing this forces a new resource to be created. -
subnet_id
- (Required) The ID of the subnet that the PostgreSQL server will be connected to. -
ignore_missing_vnet_service_endpoint
- (Optional) Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled? Defaults tofalse
.
» Attributes Reference
The following attributes are exported:
-
id
- The ID of the PostgreSQL Virtual Network Rule.
» Import
PostgreSQL Virtual Network Rules can be imported using the resource id
, e.g.
terraform import azurerm_postgresql_virtual_network_rule.rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/servers/myserver/virtualNetworkRules/vnetrulename