1. Packages
  2. Azure Native
  3. API Docs
  4. network
  5. NatRule
This is the latest version of Azure Native. Use the Azure Native v2 docs if using the v2 version of this package.
Azure Native v3.1.0 published on Tuesday, Apr 8, 2025 by Pulumi

azure-native.network.NatRule

Explore with Pulumi AI

This is the latest version of Azure Native. Use the Azure Native v2 docs if using the v2 version of this package.
Azure Native v3.1.0 published on Tuesday, Apr 8, 2025 by Pulumi

VpnGatewayNatRule Resource.

Uses Azure REST API version 2024-05-01. In version 2.x of the Azure Native provider, it used API version 2023-02-01.

Other available API versions: 2020-08-01, 2020-11-01, 2021-02-01, 2021-03-01, 2021-05-01, 2021-08-01, 2022-01-01, 2022-05-01, 2022-07-01, 2022-09-01, 2022-11-01, 2023-02-01, 2023-04-01, 2023-05-01, 2023-06-01, 2023-09-01, 2023-11-01, 2024-01-01, 2024-03-01. These can be accessed by generating a local SDK package using the CLI command pulumi package add azure-native network [ApiVersion]. See the version guide for details.

Example Usage

NatRulePut

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var natRule = new AzureNative.Network.NatRule("natRule", new()
    {
        ExternalMappings = new[]
        {
            new AzureNative.Network.Inputs.VpnNatRuleMappingArgs
            {
                AddressSpace = "192.168.21.0/24",
            },
        },
        GatewayName = "gateway1",
        InternalMappings = new[]
        {
            new AzureNative.Network.Inputs.VpnNatRuleMappingArgs
            {
                AddressSpace = "10.4.0.0/24",
            },
        },
        IpConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default",
        Mode = AzureNative.Network.VpnNatRuleMode.EgressSnat,
        NatRuleName = "natRule1",
        ResourceGroupName = "rg1",
        Type = AzureNative.Network.VpnNatRuleType.Static,
    });

});
Copy
package main

import (
	network "github.com/pulumi/pulumi-azure-native-sdk/network/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := network.NewNatRule(ctx, "natRule", &network.NatRuleArgs{
			ExternalMappings: network.VpnNatRuleMappingArray{
				&network.VpnNatRuleMappingArgs{
					AddressSpace: pulumi.String("192.168.21.0/24"),
				},
			},
			GatewayName: pulumi.String("gateway1"),
			InternalMappings: network.VpnNatRuleMappingArray{
				&network.VpnNatRuleMappingArgs{
					AddressSpace: pulumi.String("10.4.0.0/24"),
				},
			},
			IpConfigurationId: pulumi.String("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default"),
			Mode:              pulumi.String(network.VpnNatRuleModeEgressSnat),
			NatRuleName:       pulumi.String("natRule1"),
			ResourceGroupName: pulumi.String("rg1"),
			Type:              pulumi.String(network.VpnNatRuleTypeStatic),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.network.NatRule;
import com.pulumi.azurenative.network.NatRuleArgs;
import com.pulumi.azurenative.network.inputs.VpnNatRuleMappingArgs;
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 natRule = new NatRule("natRule", NatRuleArgs.builder()
            .externalMappings(VpnNatRuleMappingArgs.builder()
                .addressSpace("192.168.21.0/24")
                .build())
            .gatewayName("gateway1")
            .internalMappings(VpnNatRuleMappingArgs.builder()
                .addressSpace("10.4.0.0/24")
                .build())
            .ipConfigurationId("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default")
            .mode("EgressSnat")
            .natRuleName("natRule1")
            .resourceGroupName("rg1")
            .type("Static")
            .build());

    }
}
Copy
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const natRule = new azure_native.network.NatRule("natRule", {
    externalMappings: [{
        addressSpace: "192.168.21.0/24",
    }],
    gatewayName: "gateway1",
    internalMappings: [{
        addressSpace: "10.4.0.0/24",
    }],
    ipConfigurationId: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default",
    mode: azure_native.network.VpnNatRuleMode.EgressSnat,
    natRuleName: "natRule1",
    resourceGroupName: "rg1",
    type: azure_native.network.VpnNatRuleType.Static,
});
Copy
import pulumi
import pulumi_azure_native as azure_native

nat_rule = azure_native.network.NatRule("natRule",
    external_mappings=[{
        "address_space": "192.168.21.0/24",
    }],
    gateway_name="gateway1",
    internal_mappings=[{
        "address_space": "10.4.0.0/24",
    }],
    ip_configuration_id="/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default",
    mode=azure_native.network.VpnNatRuleMode.EGRESS_SNAT,
    nat_rule_name="natRule1",
    resource_group_name="rg1",
    type=azure_native.network.VpnNatRuleType.STATIC)
Copy
resources:
  natRule:
    type: azure-native:network:NatRule
    properties:
      externalMappings:
        - addressSpace: 192.168.21.0/24
      gatewayName: gateway1
      internalMappings:
        - addressSpace: 10.4.0.0/24
      ipConfigurationId: /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default
      mode: EgressSnat
      natRuleName: natRule1
      resourceGroupName: rg1
      type: Static
Copy

Create NatRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new NatRule(name: string, args: NatRuleArgs, opts?: CustomResourceOptions);
@overload
def NatRule(resource_name: str,
            args: NatRuleInitArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def NatRule(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            gateway_name: Optional[str] = None,
            resource_group_name: Optional[str] = None,
            external_mappings: Optional[Sequence[VpnNatRuleMappingArgs]] = None,
            id: Optional[str] = None,
            internal_mappings: Optional[Sequence[VpnNatRuleMappingArgs]] = None,
            ip_configuration_id: Optional[str] = None,
            mode: Optional[Union[str, VpnNatRuleMode]] = None,
            name: Optional[str] = None,
            nat_rule_name: Optional[str] = None,
            type: Optional[Union[str, VpnNatRuleType]] = None)
func NewNatRule(ctx *Context, name string, args NatRuleArgs, opts ...ResourceOption) (*NatRule, error)
public NatRule(string name, NatRuleArgs args, CustomResourceOptions? opts = null)
public NatRule(String name, NatRuleArgs args)
public NatRule(String name, NatRuleArgs args, CustomResourceOptions options)
type: azure-native:network:NatRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

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

Constructor example

The following reference example uses placeholder values for all input properties.

var natRuleResource = new AzureNative.Network.NatRule("natRuleResource", new()
{
    GatewayName = "string",
    ResourceGroupName = "string",
    ExternalMappings = new[]
    {
        new AzureNative.Network.Inputs.VpnNatRuleMappingArgs
        {
            AddressSpace = "string",
            PortRange = "string",
        },
    },
    Id = "string",
    InternalMappings = new[]
    {
        new AzureNative.Network.Inputs.VpnNatRuleMappingArgs
        {
            AddressSpace = "string",
            PortRange = "string",
        },
    },
    IpConfigurationId = "string",
    Mode = "string",
    Name = "string",
    NatRuleName = "string",
    Type = "string",
});
Copy
example, err := network.NewNatRule(ctx, "natRuleResource", &network.NatRuleArgs{
	GatewayName:       pulumi.String("string"),
	ResourceGroupName: pulumi.String("string"),
	ExternalMappings: network.VpnNatRuleMappingArray{
		&network.VpnNatRuleMappingArgs{
			AddressSpace: pulumi.String("string"),
			PortRange:    pulumi.String("string"),
		},
	},
	Id: pulumi.String("string"),
	InternalMappings: network.VpnNatRuleMappingArray{
		&network.VpnNatRuleMappingArgs{
			AddressSpace: pulumi.String("string"),
			PortRange:    pulumi.String("string"),
		},
	},
	IpConfigurationId: pulumi.String("string"),
	Mode:              pulumi.String("string"),
	Name:              pulumi.String("string"),
	NatRuleName:       pulumi.String("string"),
	Type:              pulumi.String("string"),
})
Copy
var natRuleResource = new NatRule("natRuleResource", NatRuleArgs.builder()
    .gatewayName("string")
    .resourceGroupName("string")
    .externalMappings(VpnNatRuleMappingArgs.builder()
        .addressSpace("string")
        .portRange("string")
        .build())
    .id("string")
    .internalMappings(VpnNatRuleMappingArgs.builder()
        .addressSpace("string")
        .portRange("string")
        .build())
    .ipConfigurationId("string")
    .mode("string")
    .name("string")
    .natRuleName("string")
    .type("string")
    .build());
Copy
nat_rule_resource = azure_native.network.NatRule("natRuleResource",
    gateway_name="string",
    resource_group_name="string",
    external_mappings=[{
        "address_space": "string",
        "port_range": "string",
    }],
    id="string",
    internal_mappings=[{
        "address_space": "string",
        "port_range": "string",
    }],
    ip_configuration_id="string",
    mode="string",
    name="string",
    nat_rule_name="string",
    type="string")
Copy
const natRuleResource = new azure_native.network.NatRule("natRuleResource", {
    gatewayName: "string",
    resourceGroupName: "string",
    externalMappings: [{
        addressSpace: "string",
        portRange: "string",
    }],
    id: "string",
    internalMappings: [{
        addressSpace: "string",
        portRange: "string",
    }],
    ipConfigurationId: "string",
    mode: "string",
    name: "string",
    natRuleName: "string",
    type: "string",
});
Copy
type: azure-native:network:NatRule
properties:
    externalMappings:
        - addressSpace: string
          portRange: string
    gatewayName: string
    id: string
    internalMappings:
        - addressSpace: string
          portRange: string
    ipConfigurationId: string
    mode: string
    name: string
    natRuleName: string
    resourceGroupName: string
    type: string
Copy

NatRule Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The NatRule resource accepts the following input properties:

GatewayName
This property is required.
Changes to this property will trigger replacement.
string
The name of the gateway.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The resource group name of the VpnGateway.
ExternalMappings List<Pulumi.AzureNative.Network.Inputs.VpnNatRuleMapping>
The private IP address external mapping for NAT.
Id string
Resource ID.
InternalMappings List<Pulumi.AzureNative.Network.Inputs.VpnNatRuleMapping>
The private IP address internal mapping for NAT.
IpConfigurationId string
The IP Configuration ID this NAT rule applies to.
Mode string | Pulumi.AzureNative.Network.VpnNatRuleMode
The Source NAT direction of a VPN NAT.
Name string
The name of the resource that is unique within a resource group. This name can be used to access the resource.
NatRuleName Changes to this property will trigger replacement. string
The name of the nat rule.
Type string | Pulumi.AzureNative.Network.VpnNatRuleType
The type of NAT rule for VPN NAT.
GatewayName
This property is required.
Changes to this property will trigger replacement.
string
The name of the gateway.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The resource group name of the VpnGateway.
ExternalMappings []VpnNatRuleMappingArgs
The private IP address external mapping for NAT.
Id string
Resource ID.
InternalMappings []VpnNatRuleMappingArgs
The private IP address internal mapping for NAT.
IpConfigurationId string
The IP Configuration ID this NAT rule applies to.
Mode string | VpnNatRuleMode
The Source NAT direction of a VPN NAT.
Name string
The name of the resource that is unique within a resource group. This name can be used to access the resource.
NatRuleName Changes to this property will trigger replacement. string
The name of the nat rule.
Type string | VpnNatRuleType
The type of NAT rule for VPN NAT.
gatewayName
This property is required.
Changes to this property will trigger replacement.
String
The name of the gateway.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The resource group name of the VpnGateway.
externalMappings List<VpnNatRuleMapping>
The private IP address external mapping for NAT.
id String
Resource ID.
internalMappings List<VpnNatRuleMapping>
The private IP address internal mapping for NAT.
ipConfigurationId String
The IP Configuration ID this NAT rule applies to.
mode String | VpnNatRuleMode
The Source NAT direction of a VPN NAT.
name String
The name of the resource that is unique within a resource group. This name can be used to access the resource.
natRuleName Changes to this property will trigger replacement. String
The name of the nat rule.
type String | VpnNatRuleType
The type of NAT rule for VPN NAT.
gatewayName
This property is required.
Changes to this property will trigger replacement.
string
The name of the gateway.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The resource group name of the VpnGateway.
externalMappings VpnNatRuleMapping[]
The private IP address external mapping for NAT.
id string
Resource ID.
internalMappings VpnNatRuleMapping[]
The private IP address internal mapping for NAT.
ipConfigurationId string
The IP Configuration ID this NAT rule applies to.
mode string | VpnNatRuleMode
The Source NAT direction of a VPN NAT.
name string
The name of the resource that is unique within a resource group. This name can be used to access the resource.
natRuleName Changes to this property will trigger replacement. string
The name of the nat rule.
type string | VpnNatRuleType
The type of NAT rule for VPN NAT.
gateway_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the gateway.
resource_group_name
This property is required.
Changes to this property will trigger replacement.
str
The resource group name of the VpnGateway.
external_mappings Sequence[VpnNatRuleMappingArgs]
The private IP address external mapping for NAT.
id str
Resource ID.
internal_mappings Sequence[VpnNatRuleMappingArgs]
The private IP address internal mapping for NAT.
ip_configuration_id str
The IP Configuration ID this NAT rule applies to.
mode str | VpnNatRuleMode
The Source NAT direction of a VPN NAT.
name str
The name of the resource that is unique within a resource group. This name can be used to access the resource.
nat_rule_name Changes to this property will trigger replacement. str
The name of the nat rule.
type str | VpnNatRuleType
The type of NAT rule for VPN NAT.
gatewayName
This property is required.
Changes to this property will trigger replacement.
String
The name of the gateway.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The resource group name of the VpnGateway.
externalMappings List<Property Map>
The private IP address external mapping for NAT.
id String
Resource ID.
internalMappings List<Property Map>
The private IP address internal mapping for NAT.
ipConfigurationId String
The IP Configuration ID this NAT rule applies to.
mode String | "EgressSnat" | "IngressSnat"
The Source NAT direction of a VPN NAT.
name String
The name of the resource that is unique within a resource group. This name can be used to access the resource.
natRuleName Changes to this property will trigger replacement. String
The name of the nat rule.
type String | "Static" | "Dynamic"
The type of NAT rule for VPN NAT.

Outputs

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

AzureApiVersion string
The Azure API version of the resource.
EgressVpnSiteLinkConnections List<Pulumi.AzureNative.Network.Outputs.SubResourceResponse>
List of egress VpnSiteLinkConnections.
Etag string
A unique read-only string that changes whenever the resource is updated.
Id string
The provider-assigned unique ID for this managed resource.
IngressVpnSiteLinkConnections List<Pulumi.AzureNative.Network.Outputs.SubResourceResponse>
List of ingress VpnSiteLinkConnections.
ProvisioningState string
The provisioning state of the NAT Rule resource.
AzureApiVersion string
The Azure API version of the resource.
EgressVpnSiteLinkConnections []SubResourceResponse
List of egress VpnSiteLinkConnections.
Etag string
A unique read-only string that changes whenever the resource is updated.
Id string
The provider-assigned unique ID for this managed resource.
IngressVpnSiteLinkConnections []SubResourceResponse
List of ingress VpnSiteLinkConnections.
ProvisioningState string
The provisioning state of the NAT Rule resource.
azureApiVersion String
The Azure API version of the resource.
egressVpnSiteLinkConnections List<SubResourceResponse>
List of egress VpnSiteLinkConnections.
etag String
A unique read-only string that changes whenever the resource is updated.
id String
The provider-assigned unique ID for this managed resource.
ingressVpnSiteLinkConnections List<SubResourceResponse>
List of ingress VpnSiteLinkConnections.
provisioningState String
The provisioning state of the NAT Rule resource.
azureApiVersion string
The Azure API version of the resource.
egressVpnSiteLinkConnections SubResourceResponse[]
List of egress VpnSiteLinkConnections.
etag string
A unique read-only string that changes whenever the resource is updated.
id string
The provider-assigned unique ID for this managed resource.
ingressVpnSiteLinkConnections SubResourceResponse[]
List of ingress VpnSiteLinkConnections.
provisioningState string
The provisioning state of the NAT Rule resource.
azure_api_version str
The Azure API version of the resource.
egress_vpn_site_link_connections Sequence[SubResourceResponse]
List of egress VpnSiteLinkConnections.
etag str
A unique read-only string that changes whenever the resource is updated.
id str
The provider-assigned unique ID for this managed resource.
ingress_vpn_site_link_connections Sequence[SubResourceResponse]
List of ingress VpnSiteLinkConnections.
provisioning_state str
The provisioning state of the NAT Rule resource.
azureApiVersion String
The Azure API version of the resource.
egressVpnSiteLinkConnections List<Property Map>
List of egress VpnSiteLinkConnections.
etag String
A unique read-only string that changes whenever the resource is updated.
id String
The provider-assigned unique ID for this managed resource.
ingressVpnSiteLinkConnections List<Property Map>
List of ingress VpnSiteLinkConnections.
provisioningState String
The provisioning state of the NAT Rule resource.

Supporting Types

SubResourceResponse
, SubResourceResponseArgs

Id string
Resource ID.
Id string
Resource ID.
id String
Resource ID.
id string
Resource ID.
id str
Resource ID.
id String
Resource ID.

VpnNatRuleMapping
, VpnNatRuleMappingArgs

AddressSpace string
Address space for Vpn NatRule mapping.
PortRange string
Port range for Vpn NatRule mapping.
AddressSpace string
Address space for Vpn NatRule mapping.
PortRange string
Port range for Vpn NatRule mapping.
addressSpace String
Address space for Vpn NatRule mapping.
portRange String
Port range for Vpn NatRule mapping.
addressSpace string
Address space for Vpn NatRule mapping.
portRange string
Port range for Vpn NatRule mapping.
address_space str
Address space for Vpn NatRule mapping.
port_range str
Port range for Vpn NatRule mapping.
addressSpace String
Address space for Vpn NatRule mapping.
portRange String
Port range for Vpn NatRule mapping.

VpnNatRuleMappingResponse
, VpnNatRuleMappingResponseArgs

AddressSpace string
Address space for Vpn NatRule mapping.
PortRange string
Port range for Vpn NatRule mapping.
AddressSpace string
Address space for Vpn NatRule mapping.
PortRange string
Port range for Vpn NatRule mapping.
addressSpace String
Address space for Vpn NatRule mapping.
portRange String
Port range for Vpn NatRule mapping.
addressSpace string
Address space for Vpn NatRule mapping.
portRange string
Port range for Vpn NatRule mapping.
address_space str
Address space for Vpn NatRule mapping.
port_range str
Port range for Vpn NatRule mapping.
addressSpace String
Address space for Vpn NatRule mapping.
portRange String
Port range for Vpn NatRule mapping.

VpnNatRuleMode
, VpnNatRuleModeArgs

EgressSnat
EgressSnat
IngressSnat
IngressSnat
VpnNatRuleModeEgressSnat
EgressSnat
VpnNatRuleModeIngressSnat
IngressSnat
EgressSnat
EgressSnat
IngressSnat
IngressSnat
EgressSnat
EgressSnat
IngressSnat
IngressSnat
EGRESS_SNAT
EgressSnat
INGRESS_SNAT
IngressSnat
"EgressSnat"
EgressSnat
"IngressSnat"
IngressSnat

VpnNatRuleType
, VpnNatRuleTypeArgs

Static
Static
Dynamic
Dynamic
VpnNatRuleTypeStatic
Static
VpnNatRuleTypeDynamic
Dynamic
Static
Static
Dynamic
Dynamic
Static
Static
Dynamic
Dynamic
STATIC
Static
DYNAMIC
Dynamic
"Static"
Static
"Dynamic"
Dynamic

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:network:NatRule natRule1 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/natRules/{natRuleName} 
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure Native pulumi/pulumi-azure-native
License
Apache-2.0
This is the latest version of Azure Native. Use the Azure Native v2 docs if using the v2 version of this package.
Azure Native v3.1.0 published on Tuesday, Apr 8, 2025 by Pulumi