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
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
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
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
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
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
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
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
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
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
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 {
Parameters
-
custom_dns_configs
optional computed - list of object-
fqdn
- string -
ip_addresses
- list of string
-
-
id
optional computed - string -
location
required - string -
name
required - string -
private_dns_zone_configs
optional computed - list of object-
id
- string -
name
- string -
private_dns_zone_id
- string -
record_sets
- list of object-
fqdn
- string -
ip_addresses
- list of string -
name
- string -
ttl
- number -
type
- string
-
-
-
resource_group_name
required - string -
subnet_id
required - string -
tags
optional - map from string to string -
private_dns_zone_group
list block-
id
optional computed - string -
name
required - string -
private_dns_zone_ids
required - list of string
-
-
private_service_connection
list block-
is_manual_connection
required - bool -
name
required - string -
private_connection_resource_alias
optional - string -
private_connection_resource_id
optional - string -
private_ip_address
optional computed - string -
request_message
optional - string -
subresource_names
optional - list of string
-
-
timeouts
single block
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.
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.
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.
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.
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
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-05-01",
"name": "[variables('privateEndpointNamePortal')]",
"tags": "[variables('tags')]",
"dependsOn": [
"[resourceId('Microsoft.Purview/accounts', variables('purviewName'))]"
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-03-01",
"properties": {
"subnet": {
"id": "[parameters('subnet')]"
},
"type": "Microsoft.Network/privateEndpoints",
"name": "[variables('privateEndpointStorageBlobName')]",
"apiVersion": "2019-11-01",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('widgetOrdersStorageAccountName'))]",
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-04-01",
"name": "[parameters('blobStorageAccountPrivateEndpointNameBLOB')]",
"location": "[resourceGroup().location]",
"properties": {
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2021-02-01",
"name": "[variables('privateEndpointStorageFileName')]",
"location": "[parameters('location')]",
"properties": {
"subnet": {
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-05-01",
"name": "[variables('privateEndpointNameSql')]",
"dependsOn": [
"[resourceId('Microsoft.Synapse/workspaces', variables('synapseWorkspaceName'))]"
],
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-05-01",
"name": "[variables('privateEndpointName')]",
"location": "[variables('privateEndpointLocation')]",
"properties": {
"privateLinkServiceConnections": [
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-04-01",
"name": "[parameters('blobStorageAccountPrivateEndpointNameBLOB')]",
"location": "[resourceGroup().location]",
"properties": {
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-06-01",
"name": "[parameters('adfPEName')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"dependsOn": [
"type": "Microsoft.Network/privateEndpoints",
"location": "[parameters('privateLinkLocation')]",
"properties": {
"privateLinkServiceConnections": [
{
"name": "[variables('storageAccountPrivateEndpointName')]",
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
extendedLocation
optionalname
required - stringThe name of the extended location.
type
required - stringThe type of the extended location.
properties
requiredsubnet
optionalid
required - stringResource ID.
privateLinkServiceConnections
optional arrayproperties
optionalprivateLinkServiceId
optional - stringThe resource id of private link service.
groupIds
optional - arrayThe ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.
requestMessage
optional - stringA message passed to the owner of the remote resource with this connection request. Restricted to 140 chars.
privateLinkServiceConnectionState
optionalstatus
optional - stringIndicates whether the connection has been Approved/Rejected/Removed by the owner of the service.
description
optional - stringThe reason for approval/rejection of the connection.
actionsRequired
optional - stringA message indicating if changes on the service provider require any updates on the consumer.
name
optional - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
manualPrivateLinkServiceConnections
optional arrayproperties
optionalprivateLinkServiceId
optional - stringThe resource id of private link service.
groupIds
optional - arrayThe ID(s) of the group(s) obtained from the remote resource that this private endpoint should connect to.
requestMessage
optional - stringA message passed to the owner of the remote resource with this connection request. Restricted to 140 chars.
privateLinkServiceConnectionState
optionalstatus
optional - stringIndicates whether the connection has been Approved/Rejected/Removed by the owner of the service.
description
optional - stringThe reason for approval/rejection of the connection.
actionsRequired
optional - stringA message indicating if changes on the service provider require any updates on the consumer.
name
optional - stringThe name of the resource that is unique within a resource group. This name can be used to access the resource.
customDnsConfigs
optional arrayfqdn
optional - stringFqdn that resolves to private endpoint ip address.
ipAddresses
optional - arrayA 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.