Azure Network Private Link Service

This page shows how to write Terraform and Azure Resource Manager for Network Private Link Service and write them securely.

azurerm_private_link_service (Terraform)

The Private Link Service in Network can be configured in Terraform with the resource name azurerm_private_link_service. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

private_link.tf#L1
resource "azurerm_private_link_service" "mktp-fin-prod-mongodb" {
  name                = "mktp-fin-prod-mongodb"
  resource_group_name = azurerm_resource_group.Financial-prod-vnet-enpoint.name
  location            = var.BRS

  auto_approval_subscription_ids              = ["4220b454-81b6-4e1a-8f57-4bb445ff0992"]
main.tf#L2
resource "azurerm_private_link_service" "pls" {
  name                                          = var.pls_name
  resource_group_name                           = var.rg.name
  location                                      = var.rg.location
  enable_proxy_protocol                         = true

pls.tf#L1
resource "azurerm_private_link_service" "pls" {
  count                                       = var.enable_pls ? 1 : 0
  name                                        = var.pls_name
  resource_group_name                         = var.resource_group_name
  location                                    = var.location
  auto_approval_subscription_ids              = var.auto_approval_subscription_ids
private_link.tf#L1
resource "azurerm_private_link_service" "wowza" {
  name                = var.service_name

  resource_group_name = azurerm_resource_group.wowza.name
  location            = azurerm_resource_group.wowza.location

pls.tf#L5
resource "azurerm_private_link_service" "pls" {
  name                = "Web-pls"
  resource_group_name = azurerm_resource_group.plspenat.name
  location            = azurerm_resource_group.plspenat.location

  auto_approval_subscription_ids              = [data.azurerm_subscription.this.subscription_id]
privatelink.tf#L1
resource "azurerm_private_link_service" "demo" {
  name                = var.private_link_name
  resource_group_name = var.rg_name
  location            = var.location

  #auto_approval_subscription_ids              = ["00000000-0000-0000-0000-000000000000"]
main.tf#L45
resource "azurerm_private_link_service" "test" {
  name                = "acctestpls"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name

  nat_ip_configuration {
modules.tf#L43
resource "azurerm_private_link_service" "example" {
  name                = "example-privatelink"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  nat_ip_configuration {
modules.tf#L43
resource "azurerm_private_link_service" "example" {
  name                = "example-privatelink"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  nat_ip_configuration {
main.tf#L45
resource "azurerm_private_link_service" "test" {
  name                = "acctestpls"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name

  nat_ip_configuration {

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Private Link Service. -> NOTE Private Link is now in GA.

Tips: Best Practices for The Other Azure Network Resources

In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_network_security_group

Ensure to disable RDP port from the Internet

It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.

risk-label

azurerm_network_security_rule

Ensure to set a more restrictive CIDR range for ingress from the internet

It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.

risk-label

azurerm_network_watcher_flow_log

Ensure to enable Retention policy for flow logs and set it to enough duration

It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.

Review your Azure Network settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Network/privateLinkServices (Azure Resource Manager)

The privateLinkServices in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/privateLinkServices. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

private-link-template.json#L34
            "type": "Microsoft.Network/privateLinkServices",
            "apiVersion": "2020-05-01",
            "location": "[resourceGroup().location]",
            "name": "[concat(parameters('resourceNamePrefix'), 'private-link-', parameters('priveteLinkType'))]",
            "properties": {
                "autoApproval": {
PrivateLinkServiceList.json#L14
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceListAll.json#L13
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceListAll.json#L13
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceListAll.json#L13
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceList.json#L14
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceList.json#L14
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceListAll.json#L13
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceListAll.json#L13
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [
PrivateLinkServiceList.json#L14
            "type": "Microsoft.Network/privateLinkServices",
            "location": "eastus",
            "properties": {
              "provisioningState": "Succeeded",
              "visibility": {
                "subscriptions": [

Parameters

  • name required - string
  • type required - string
  • apiVersion required - string
  • location required - string

    Resource location.

  • tags optional - string

    Resource tags.

  • extendedLocation optional
      • name required - string

        The name of the extended location.

      • type required - string

        The type of the extended location.

  • properties required
      • loadBalancerFrontendIpConfigurations optional array
          • id required - string

            Resource ID.

      • ipConfigurations optional array
          • properties optional
              • privateIPAddress optional - string

                The private IP address of the IP configuration.

              • privateIPAllocationMethod optional - string

                The private IP address allocation method.

              • subnet optional
                  • id required - string

                    Resource ID.

              • primary optional - boolean

                Whether the ip configuration is primary or not.

              • privateIPAddressVersion optional - string

                Whether the specific IP configuration is IPv4 or IPv6. Default is IPv4.

          • name optional - string

            The name of private link service ip configuration.

      • visibility optional
          • subscriptions optional - array

            The list of subscriptions.

      • autoApproval optional
          • subscriptions optional - array

            The list of subscriptions.

      • fqdns optional - array

        The list of Fqdn.

      • enableProxyProtocol optional - boolean

        Whether the private link service is enabled for proxy protocol or not.

Frequently asked questions

Azure Network Private Link Service is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.

For Terraform, the AvocadoDevOps/azure-marketplace-prod-terraform, yz4898/att_mvm and dhileepbalaji/azure source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the mhenderson442/mercury-arm, debhol/azuredocs and debhol/azuredocs source code examples are useful. See the Azure Resource Manager Example section for further details.