Azure Network Public IP Prefix Association
This page shows how to write Terraform and Azure Resource Manager for Network Public IP Prefix Association and write them securely.
azurerm_nat_gateway_public_ip_prefix_association (Terraform)
The Public IP Prefix Association in Network can be configured in Terraform with the resource name azurerm_nat_gateway_public_ip_prefix_association
. The following sections describe 1 example of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_nat_gateway_public_ip_prefix_association" "azurerm_nat_gateway_public_ip_prefix_association" {
nat_gateway_id = azurerm_nat_gateway.azurerm_nat_gateway.id
public_ip_prefix_id = azurerm_public_ip_prefix.azurerm_public_ip_prefix.id
}
resource "azurerm_subnet_nat_gateway_association" "example" {
Parameters
The following arguments are supported:
nat_gateway_id
- (Required) The ID of the Nat Gateway. Changing this forces a new resource to be created.public_ip_prefix_id
- (Required) The ID of the Public IP Prefix which this Nat Gateway which should be connected to. Changing this forces a new resource to be created.
The following attributes are exported:
id
- The (Terraform specific) ID of the Association between the Nat Gateway and the Public IP Prefix.
Explanation in Terraform Registry
Manages the association between a Nat Gateway and a Public IP Prefix.
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/natGateways (Azure Resource Manager)
The natGateways in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/natGateways
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
"type": "Microsoft.Network/natGateways"
}
},
"201": {
"body": {
"name": "test-natGateway",
Parameters
name
required - stringtype
required - stringapiVersion
required - stringlocation
required - stringResource location.
tags
optional - stringResource tags.
sku
optionalname
optional - stringName of Nat Gateway SKU.
properties
requiredidleTimeoutInMinutes
optional - integerThe idle timeout of the nat gateway.
publicIpAddresses
optional arrayid
required - stringResource ID.
publicIpPrefixes
optional arrayid
required - stringResource ID.
zones
optional - arrayA list of availability zones denoting the zone in which Nat Gateway should be deployed.
Frequently asked questions
What is Azure Network Public IP Prefix Association?
Azure Network Public IP Prefix Association 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 Public IP Prefix Association?
For Terraform, the Gompei/azure-terraform source code example is useful. See the Terraform Example section for further details.
For Azure Resource Manager, the jashsing-mic/azure-rest-api-specs, jashsing-mic/azure-rest-api-specs and jashsing-mic/azure-rest-api-specs source code examples are useful. See the Azure Resource Manager Example section for further details.