azure logo
Azure Classic v5.38.0, Mar 21 23

azure.postgresql.VirtualNetworkRule

Manages a PostgreSQL Virtual Network Rule.

NOTE: PostgreSQL Virtual Network Rules can only be used with SKU Tiers of GeneralPurpose or MemoryOptimized

Example Usage

using System.Collections.Generic;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new()
    {
        AddressSpaces = new[]
        {
            "10.7.29.0/29",
        },
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
    });

    var @internal = new Azure.Network.Subnet("internal", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        VirtualNetworkName = exampleVirtualNetwork.Name,
        AddressPrefixes = new[]
        {
            "10.7.29.0/29",
        },
        ServiceEndpoints = new[]
        {
            "Microsoft.Sql",
        },
    });

    var exampleServer = new Azure.PostgreSql.Server("exampleServer", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        SkuName = "GP_Gen5_2",
        StorageMb = 5120,
        BackupRetentionDays = 7,
        AdministratorLogin = "psqladmin",
        AdministratorLoginPassword = "H@Sh1CoR3!",
        Version = "9.5",
        SslEnforcementEnabled = true,
    });

    var exampleVirtualNetworkRule = new Azure.PostgreSql.VirtualNetworkRule("exampleVirtualNetworkRule", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        ServerName = exampleServer.Name,
        SubnetId = @internal.Id,
        IgnoreMissingVnetServiceEndpoint = true,
    });

});
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/postgresql"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
			AddressSpaces: pulumi.StringArray{
				pulumi.String("10.7.29.0/29"),
			},
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
		})
		if err != nil {
			return err
		}
		internal, err := network.NewSubnet(ctx, "internal", &network.SubnetArgs{
			ResourceGroupName:  exampleResourceGroup.Name,
			VirtualNetworkName: exampleVirtualNetwork.Name,
			AddressPrefixes: pulumi.StringArray{
				pulumi.String("10.7.29.0/29"),
			},
			ServiceEndpoints: pulumi.StringArray{
				pulumi.String("Microsoft.Sql"),
			},
		})
		if err != nil {
			return err
		}
		exampleServer, err := postgresql.NewServer(ctx, "exampleServer", &postgresql.ServerArgs{
			Location:                   exampleResourceGroup.Location,
			ResourceGroupName:          exampleResourceGroup.Name,
			SkuName:                    pulumi.String("GP_Gen5_2"),
			StorageMb:                  pulumi.Int(5120),
			BackupRetentionDays:        pulumi.Int(7),
			AdministratorLogin:         pulumi.String("psqladmin"),
			AdministratorLoginPassword: pulumi.String("H@Sh1CoR3!"),
			Version:                    pulumi.String("9.5"),
			SslEnforcementEnabled:      pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = postgresql.NewVirtualNetworkRule(ctx, "exampleVirtualNetworkRule", &postgresql.VirtualNetworkRuleArgs{
			ResourceGroupName:                exampleResourceGroup.Name,
			ServerName:                       exampleServer.Name,
			SubnetId:                         internal.ID(),
			IgnoreMissingVnetServiceEndpoint: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.postgresql.Server;
import com.pulumi.azure.postgresql.ServerArgs;
import com.pulumi.azure.postgresql.VirtualNetworkRule;
import com.pulumi.azure.postgresql.VirtualNetworkRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()        
            .addressSpaces("10.7.29.0/29")
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .build());

        var internal = new Subnet("internal", SubnetArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .virtualNetworkName(exampleVirtualNetwork.name())
            .addressPrefixes("10.7.29.0/29")
            .serviceEndpoints("Microsoft.Sql")
            .build());

        var exampleServer = new Server("exampleServer", ServerArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .skuName("GP_Gen5_2")
            .storageMb(5120)
            .backupRetentionDays(7)
            .administratorLogin("psqladmin")
            .administratorLoginPassword("H@Sh1CoR3!")
            .version("9.5")
            .sslEnforcementEnabled(true)
            .build());

        var exampleVirtualNetworkRule = new VirtualNetworkRule("exampleVirtualNetworkRule", VirtualNetworkRuleArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .serverName(exampleServer.name())
            .subnetId(internal.id())
            .ignoreMissingVnetServiceEndpoint(true)
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
    address_spaces=["10.7.29.0/29"],
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name)
internal = azure.network.Subnet("internal",
    resource_group_name=example_resource_group.name,
    virtual_network_name=example_virtual_network.name,
    address_prefixes=["10.7.29.0/29"],
    service_endpoints=["Microsoft.Sql"])
example_server = azure.postgresql.Server("exampleServer",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    sku_name="GP_Gen5_2",
    storage_mb=5120,
    backup_retention_days=7,
    administrator_login="psqladmin",
    administrator_login_password="H@Sh1CoR3!",
    version="9.5",
    ssl_enforcement_enabled=True)
example_virtual_network_rule = azure.postgresql.VirtualNetworkRule("exampleVirtualNetworkRule",
    resource_group_name=example_resource_group.name,
    server_name=example_server.name,
    subnet_id=internal.id,
    ignore_missing_vnet_service_endpoint=True)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
    addressSpaces: ["10.7.29.0/29"],
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
});
const internal = new azure.network.Subnet("internal", {
    resourceGroupName: exampleResourceGroup.name,
    virtualNetworkName: exampleVirtualNetwork.name,
    addressPrefixes: ["10.7.29.0/29"],
    serviceEndpoints: ["Microsoft.Sql"],
});
const exampleServer = new azure.postgresql.Server("exampleServer", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    skuName: "GP_Gen5_2",
    storageMb: 5120,
    backupRetentionDays: 7,
    administratorLogin: "psqladmin",
    administratorLoginPassword: "H@Sh1CoR3!",
    version: "9.5",
    sslEnforcementEnabled: true,
});
const exampleVirtualNetworkRule = new azure.postgresql.VirtualNetworkRule("exampleVirtualNetworkRule", {
    resourceGroupName: exampleResourceGroup.name,
    serverName: exampleServer.name,
    subnetId: internal.id,
    ignoreMissingVnetServiceEndpoint: true,
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleVirtualNetwork:
    type: azure:network:VirtualNetwork
    properties:
      addressSpaces:
        - 10.7.29.0/29
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
  internal:
    type: azure:network:Subnet
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      virtualNetworkName: ${exampleVirtualNetwork.name}
      addressPrefixes:
        - 10.7.29.0/29
      serviceEndpoints:
        - Microsoft.Sql
  exampleServer:
    type: azure:postgresql:Server
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      skuName: GP_Gen5_2
      storageMb: 5120
      backupRetentionDays: 7
      administratorLogin: psqladmin
      administratorLoginPassword: H@Sh1CoR3!
      version: '9.5'
      sslEnforcementEnabled: true
  exampleVirtualNetworkRule:
    type: azure:postgresql:VirtualNetworkRule
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      serverName: ${exampleServer.name}
      subnetId: ${internal.id}
      ignoreMissingVnetServiceEndpoint: true

Create VirtualNetworkRule Resource

new VirtualNetworkRule(name: string, args: VirtualNetworkRuleArgs, opts?: CustomResourceOptions);
@overload
def VirtualNetworkRule(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       ignore_missing_vnet_service_endpoint: Optional[bool] = None,
                       name: Optional[str] = None,
                       resource_group_name: Optional[str] = None,
                       server_name: Optional[str] = None,
                       subnet_id: Optional[str] = None)
@overload
def VirtualNetworkRule(resource_name: str,
                       args: VirtualNetworkRuleArgs,
                       opts: Optional[ResourceOptions] = None)
func NewVirtualNetworkRule(ctx *Context, name string, args VirtualNetworkRuleArgs, opts ...ResourceOption) (*VirtualNetworkRule, error)
public VirtualNetworkRule(string name, VirtualNetworkRuleArgs args, CustomResourceOptions? opts = null)
public VirtualNetworkRule(String name, VirtualNetworkRuleArgs args)
public VirtualNetworkRule(String name, VirtualNetworkRuleArgs args, CustomResourceOptions options)
type: azure:postgresql:VirtualNetworkRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args VirtualNetworkRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args VirtualNetworkRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args VirtualNetworkRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VirtualNetworkRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args VirtualNetworkRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

VirtualNetworkRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The VirtualNetworkRule resource accepts the following input properties:

ResourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

ServerName string

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.

SubnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

IgnoreMissingVnetServiceEndpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

Name string

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.

ResourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

ServerName string

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.

SubnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

IgnoreMissingVnetServiceEndpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

Name string

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.

resourceGroupName String

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName String

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.

subnetId String

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint Boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name String

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.

resourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName string

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.

subnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name string

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.

resource_group_name str

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

server_name str

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 str

The ID of the subnet that the PostgreSQL server will be connected to.

ignore_missing_vnet_service_endpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name str

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.

resourceGroupName String

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName String

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.

subnetId String

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint Boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name String

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.

Outputs

All input properties are implicitly available as output properties. Additionally, the VirtualNetworkRule resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing VirtualNetworkRule Resource

Get an existing VirtualNetworkRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VirtualNetworkRuleState, opts?: CustomResourceOptions): VirtualNetworkRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        ignore_missing_vnet_service_endpoint: Optional[bool] = None,
        name: Optional[str] = None,
        resource_group_name: Optional[str] = None,
        server_name: Optional[str] = None,
        subnet_id: Optional[str] = None) -> VirtualNetworkRule
func GetVirtualNetworkRule(ctx *Context, name string, id IDInput, state *VirtualNetworkRuleState, opts ...ResourceOption) (*VirtualNetworkRule, error)
public static VirtualNetworkRule Get(string name, Input<string> id, VirtualNetworkRuleState? state, CustomResourceOptions? opts = null)
public static VirtualNetworkRule get(String name, Output<String> id, VirtualNetworkRuleState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
IgnoreMissingVnetServiceEndpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

Name string

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.

ResourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

ServerName string

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.

SubnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

IgnoreMissingVnetServiceEndpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

Name string

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.

ResourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

ServerName string

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.

SubnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint Boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name String

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.

resourceGroupName String

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName String

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.

subnetId String

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name string

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.

resourceGroupName string

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName string

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.

subnetId string

The ID of the subnet that the PostgreSQL server will be connected to.

ignore_missing_vnet_service_endpoint bool

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name str

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.

resource_group_name str

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

server_name str

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 str

The ID of the subnet that the PostgreSQL server will be connected to.

ignoreMissingVnetServiceEndpoint Boolean

Should the Virtual Network Rule be created before the Subnet has the Virtual Network Service Endpoint enabled?

name String

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.

resourceGroupName String

The name of the resource group where the PostgreSQL server resides. Changing this forces a new resource to be created.

serverName String

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.

subnetId String

The ID of the subnet that the PostgreSQL server will be connected to.

Import

PostgreSQL Virtual Network Rules can be imported using the resource id, e.g.

 $ pulumi import azure:postgresql/virtualNetworkRule:VirtualNetworkRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/servers/myserver/virtualNetworkRules/vnetrulename

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.