Azure Network Private Endpoint

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

azurerm_private_endpoint (Terraform)

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

Example Usage from GitHub

privateendpoint.tf#L1
resource "azurerm_private_endpoint" "table" {
  name                = local.storage_data_private_endpoint
  location            = azurerm_resource_group.spoke.location
  resource_group_name = azurerm_resource_group.spoke.name
  subnet_id           = azurerm_subnet.data.id

privateendpoint.tf#L1
resource "azurerm_private_endpoint" "acr" {
  name                = local.acr_private_endpoint
  location            = azurerm_resource_group.spoke.location
  resource_group_name = azurerm_resource_group.spoke.name
  subnet_id           = azurerm_subnet.acr.id

privateendpoint.tf#L1
resource "azurerm_private_endpoint" "table" {
  name                = local.storage_data_private_endpoint
  location            = azurerm_resource_group.spoke.location
  resource_group_name = azurerm_resource_group.spoke.name
  subnet_id           = azurerm_subnet.data.id

privateendpoint.tf#L1
resource "azurerm_private_endpoint" "table" {
  name                = local.storage_data_private_endpoint
  location            = azurerm_resource_group.spoke.location
  resource_group_name = azurerm_resource_group.spoke.name
  subnet_id           = azurerm_subnet.data.id

private_endpoint_test.tf#L35
resource "azurerm_private_endpoint" "without_usage_file" {
  name                = "example-privateendpoint"
  resource_group_name = azurerm_resource_group.main.name
  location            = azurerm_resource_group.main.location
  subnet_id           = azurerm_subnet.internal.id

private_endpoint.tf#L2
resource "azurerm_private_endpoint" "pe-mktp-fin-prod-mongodb" {
  name                = "pe-mktp-fin-prod-mongodb"
  location            = var.BRS
  subnet_id           = azurerm_subnet.vnet-fin-prod-sub02.id
  resource_group_name = azurerm_resource_group.Marketplace-financeiro-prod.name

privateendpoint.tf#L1
resource "azurerm_private_endpoint" "acr" {
  name                = local.acr_private_endpoint
  location            = azurerm_resource_group.spoke.location
  resource_group_name = azurerm_resource_group.spoke.name
  subnet_id           = azurerm_subnet.acr.id

private_endpoints.tf#L2
resource "azurerm_private_endpoint" "acr-pe" {
  name                = var.acr_pe_name
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  subnet_id           = azurerm_subnet.snet.0.id
  tags                = local.common_tags
private_endpoint_test.tf#L35
resource "azurerm_private_endpoint" "without_usage_file" {
  name                = "example-privateendpoint"
  resource_group_name = azurerm_resource_group.main.name
  location            = azurerm_resource_group.main.location
  subnet_id           = azurerm_subnet.internal.id

private-link-endpoint.tf#L256
resource "azurerm_private_endpoint" "ple-1"{
  name                  = "ple-1"
  location              = var.location-privatelink-endpoint
  resource_group_name   = azurerm_resource_group.privatelink-endpoint-rg.name
  subnet_id             = azurerm_subnet.privatelink-endpoint-source-subnet.id
  private_service_connection {

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 Endpoint. Azure Private Endpoint is a network interface that connects you privately and securely to a service powered by Azure Private Link. Private Endpoint uses a private IP address from your VNet, effectively bringing the service into your VNet. The service could be an Azure service such as Azure Storage, SQL, etc. or your own Private Link Service.

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/privateEndpoints (Azure Resource Manager)

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

Example Usage from GitHub

PurviewDeployment.json#L155
            "type": "Microsoft.Network/privateEndpoints",
            "apiVersion": "2020-05-01",
            "name": "[variables('privateEndpointNamePortal')]",
            "tags": "[variables('tags')]",
            "dependsOn": [
                "[resourceId('Microsoft.Purview/accounts', variables('purviewName'))]"
azdeployPE.json#L72
            "type": "Microsoft.Network/privateEndpoints",
            "apiVersion": "2020-03-01",
            "properties": {
                "subnet": {
                    "id": "[parameters('subnet')]"
                },
azuredeploy.json#L467
            "type": "Microsoft.Network/privateEndpoints",
            "name": "[variables('privateEndpointStorageBlobName')]",
            "apiVersion": "2019-11-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', variables('widgetOrdersStorageAccountName'))]",
05-AzureML-AllResources-PE.json#L149
      "type": "Microsoft.Network/privateEndpoints",
      "apiVersion": "2020-04-01",
      "name": "[parameters('blobStorageAccountPrivateEndpointNameBLOB')]",
      "location": "[resourceGroup().location]",

      "properties": {
azuredeploy.json#L318
      "type": "Microsoft.Network/privateEndpoints",
      "apiVersion": "2021-02-01",
      "name": "[variables('privateEndpointStorageFileName')]",
      "location": "[parameters('location')]",
      "properties": {
        "subnet": {
deploy.synapse.json#L169
            "type": "Microsoft.Network/privateEndpoints",
            "apiVersion": "2020-05-01",
            "name": "[variables('privateEndpointNameSql')]",
            "dependsOn": [
                "[resourceId('Microsoft.Synapse/workspaces', variables('synapseWorkspaceName'))]"
            ],
deploy.privateEndpoint.json#L53
            "type": "Microsoft.Network/privateEndpoints",
            "apiVersion": "2020-05-01",
            "name": "[variables('privateEndpointName')]",
            "location": "[variables('privateEndpointLocation')]",
            "properties": {
                "privateLinkServiceConnections": [
08-ADLS-Gen2-PE.json#L116
      "type": "Microsoft.Network/privateEndpoints",
      "apiVersion": "2020-04-01",
      "name": "[parameters('blobStorageAccountPrivateEndpointNameBLOB')]",
      "location": "[resourceGroup().location]",

      "properties": {
privateEndpoints-template.json#L64
      "type": "Microsoft.Network/privateEndpoints",
      "apiVersion": "2020-06-01",
      "name": "[parameters('adfPEName')]",
      "location": "[parameters('location')]",
      "tags": "[parameters('tags')]",
      "dependsOn": [
privateendpoint.template.json#L51
      "type": "Microsoft.Network/privateEndpoints",
      "location": "[parameters('privateLinkLocation')]",
      "properties": {
        "privateLinkServiceConnections": [
          {
            "name": "[variables('storageAccountPrivateEndpointName')]",

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
      • subnet optional
          • id required - string

            Resource ID.

      • privateLinkServiceConnections optional array
          • properties optional
              • privateLinkServiceId optional - string

                The resource id of private link service.

              • groupIds optional - array

                The ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.

              • requestMessage optional - string

                A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars.

              • privateLinkServiceConnectionState optional
                  • status optional - string

                    Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.

                  • description optional - string

                    The reason for approval/rejection of the connection.

                  • actionsRequired optional - string

                    A message indicating if changes on the service provider require any updates on the consumer.

          • name optional - string

            The name of the resource that is unique within a resource group. This name can be used to access the resource.

      • manualPrivateLinkServiceConnections optional array
          • properties optional
              • privateLinkServiceId optional - string

                The resource id of private link service.

              • groupIds optional - array

                The ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.

              • requestMessage optional - string

                A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars.

              • privateLinkServiceConnectionState optional
                  • status optional - string

                    Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.

                  • description optional - string

                    The reason for approval/rejection of the connection.

                  • actionsRequired optional - string

                    A message indicating if changes on the service provider require any updates on the consumer.

          • name optional - string

            The name of the resource that is unique within a resource group. This name can be used to access the resource.

      • customDnsConfigs optional array
          • fqdn optional - string

            Fqdn that resolves to private endpoint ip address.

          • ipAddresses optional - array

            A list of private ip addresses of the private endpoint.

Frequently asked questions

What is Azure Network Private Endpoint?

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

Where can I find the example code for the Azure Network Private Endpoint?

For Terraform, the fortunkam/asev3-firewall-appgateway, fortunkam/aks-private-cluster-landing-zone and fortunkam/apim-function-privatelink source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the zeinab-mk/Purview, vsuopys/SecureSynapse and Azure-Samples/Azure-Functions-Private-Endpoints source code examples are useful. See the Azure Resource Manager Example section for further details.