1. Packages
  2. Ionoscloud
  3. API Docs
  4. compute
  5. NatGatewayRule
IonosCloud v0.2.2 published on Monday, May 12, 2025 by ionos-cloud

ionoscloud.compute.NatGatewayRule

Explore with Pulumi AI

ionoscloud logo
IonosCloud v0.2.2 published on Monday, May 12, 2025 by ionos-cloud

    Manages a Nat Gateway Rule on IonosCloud.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ionoscloud from "@ionos-cloud/sdk-pulumi";
    
    const example = new ionoscloud.compute.Datacenter("example", {
        name: "Datacenter Example",
        location: "us/las",
        description: "Datacenter Description",
        secAuthProtection: false,
    });
    const exampleIPBlock = new ionoscloud.compute.IPBlock("example", {
        location: "us/las",
        size: 2,
        name: "IP Block Example",
    });
    const exampleLan = new ionoscloud.compute.Lan("example", {
        datacenterId: example.id,
        "public": true,
        name: "Lan Example",
    });
    const exampleNatGateway = new ionoscloud.compute.NatGateway("example", {
        datacenterId: example.id,
        name: "example",
        publicIps: [
            exampleIPBlock.ips[0],
            exampleIPBlock.ips[1],
        ],
        lans: [{
            id: exampleLan.id,
            gatewayIps: ["10.11.2.5"],
        }],
    });
    const exampleNatGatewayRule = new ionoscloud.compute.NatGatewayRule("example", {
        datacenterId: example.id,
        natgatewayId: exampleNatGateway.id,
        name: "example",
        type: "SNAT",
        protocol: "TCP",
        sourceSubnet: "10.0.1.0/24",
        publicIp: exampleIPBlock.ips[0],
        targetSubnet: "10.0.1.0/24",
        targetPortRange: {
            start: 500,
            end: 1000,
        },
    });
    
    import pulumi
    import pulumi_ionoscloud as ionoscloud
    
    example = ionoscloud.compute.Datacenter("example",
        name="Datacenter Example",
        location="us/las",
        description="Datacenter Description",
        sec_auth_protection=False)
    example_ip_block = ionoscloud.compute.IPBlock("example",
        location="us/las",
        size=2,
        name="IP Block Example")
    example_lan = ionoscloud.compute.Lan("example",
        datacenter_id=example.id,
        public=True,
        name="Lan Example")
    example_nat_gateway = ionoscloud.compute.NatGateway("example",
        datacenter_id=example.id,
        name="example",
        public_ips=[
            example_ip_block.ips[0],
            example_ip_block.ips[1],
        ],
        lans=[{
            "id": example_lan.id,
            "gateway_ips": ["10.11.2.5"],
        }])
    example_nat_gateway_rule = ionoscloud.compute.NatGatewayRule("example",
        datacenter_id=example.id,
        natgateway_id=example_nat_gateway.id,
        name="example",
        type="SNAT",
        protocol="TCP",
        source_subnet="10.0.1.0/24",
        public_ip=example_ip_block.ips[0],
        target_subnet="10.0.1.0/24",
        target_port_range={
            "start": 500,
            "end": 1000,
        })
    
    package main
    
    import (
    	"github.com/ionos-cloud/pulumi-ionoscloud/sdk/go/ionoscloud/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := compute.NewDatacenter(ctx, "example", &compute.DatacenterArgs{
    			Name:              pulumi.String("Datacenter Example"),
    			Location:          pulumi.String("us/las"),
    			Description:       pulumi.String("Datacenter Description"),
    			SecAuthProtection: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		exampleIPBlock, err := compute.NewIPBlock(ctx, "example", &compute.IPBlockArgs{
    			Location: pulumi.String("us/las"),
    			Size:     pulumi.Int(2),
    			Name:     pulumi.String("IP Block Example"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleLan, err := compute.NewLan(ctx, "example", &compute.LanArgs{
    			DatacenterId: example.ID(),
    			Public:       pulumi.Bool(true),
    			Name:         pulumi.String("Lan Example"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleNatGateway, err := compute.NewNatGateway(ctx, "example", &compute.NatGatewayArgs{
    			DatacenterId: example.ID(),
    			Name:         pulumi.String("example"),
    			PublicIps: pulumi.StringArray{
    				exampleIPBlock.Ips.ApplyT(func(ips []string) (string, error) {
    					return ips[0], nil
    				}).(pulumi.StringOutput),
    				exampleIPBlock.Ips.ApplyT(func(ips []string) (string, error) {
    					return ips[1], nil
    				}).(pulumi.StringOutput),
    			},
    			Lans: compute.NatGatewayLanArray{
    				&compute.NatGatewayLanArgs{
    					Id: exampleLan.ID(),
    					GatewayIps: pulumi.StringArray{
    						pulumi.String("10.11.2.5"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewNatGatewayRule(ctx, "example", &compute.NatGatewayRuleArgs{
    			DatacenterId: example.ID(),
    			NatgatewayId: exampleNatGateway.ID(),
    			Name:         pulumi.String("example"),
    			Type:         pulumi.String("SNAT"),
    			Protocol:     pulumi.String("TCP"),
    			SourceSubnet: pulumi.String("10.0.1.0/24"),
    			PublicIp: exampleIPBlock.Ips.ApplyT(func(ips []string) (string, error) {
    				return ips[0], nil
    			}).(pulumi.StringOutput),
    			TargetSubnet: pulumi.String("10.0.1.0/24"),
    			TargetPortRange: &compute.NatGatewayRuleTargetPortRangeArgs{
    				Start: pulumi.Int(500),
    				End:   pulumi.Int(1000),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ionoscloud = Ionoscloud.Pulumi.Ionoscloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Ionoscloud.Compute.Datacenter("example", new()
        {
            Name = "Datacenter Example",
            Location = "us/las",
            Description = "Datacenter Description",
            SecAuthProtection = false,
        });
    
        var exampleIPBlock = new Ionoscloud.Compute.IPBlock("example", new()
        {
            Location = "us/las",
            Size = 2,
            Name = "IP Block Example",
        });
    
        var exampleLan = new Ionoscloud.Compute.Lan("example", new()
        {
            DatacenterId = example.Id,
            Public = true,
            Name = "Lan Example",
        });
    
        var exampleNatGateway = new Ionoscloud.Compute.NatGateway("example", new()
        {
            DatacenterId = example.Id,
            Name = "example",
            PublicIps = new[]
            {
                exampleIPBlock.Ips.Apply(ips => ips[0]),
                exampleIPBlock.Ips.Apply(ips => ips[1]),
            },
            Lans = new[]
            {
                new Ionoscloud.Compute.Inputs.NatGatewayLanArgs
                {
                    Id = exampleLan.Id,
                    GatewayIps = new[]
                    {
                        "10.11.2.5",
                    },
                },
            },
        });
    
        var exampleNatGatewayRule = new Ionoscloud.Compute.NatGatewayRule("example", new()
        {
            DatacenterId = example.Id,
            NatgatewayId = exampleNatGateway.Id,
            Name = "example",
            Type = "SNAT",
            Protocol = "TCP",
            SourceSubnet = "10.0.1.0/24",
            PublicIp = exampleIPBlock.Ips.Apply(ips => ips[0]),
            TargetSubnet = "10.0.1.0/24",
            TargetPortRange = new Ionoscloud.Compute.Inputs.NatGatewayRuleTargetPortRangeArgs
            {
                Start = 500,
                End = 1000,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ionoscloud.compute.Datacenter;
    import com.pulumi.ionoscloud.compute.DatacenterArgs;
    import com.pulumi.ionoscloud.compute.IPBlock;
    import com.pulumi.ionoscloud.compute.IPBlockArgs;
    import com.pulumi.ionoscloud.compute.Lan;
    import com.pulumi.ionoscloud.compute.LanArgs;
    import com.pulumi.ionoscloud.compute.NatGateway;
    import com.pulumi.ionoscloud.compute.NatGatewayArgs;
    import com.pulumi.ionoscloud.compute.inputs.NatGatewayLanArgs;
    import com.pulumi.ionoscloud.compute.NatGatewayRule;
    import com.pulumi.ionoscloud.compute.NatGatewayRuleArgs;
    import com.pulumi.ionoscloud.compute.inputs.NatGatewayRuleTargetPortRangeArgs;
    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 example = new Datacenter("example", DatacenterArgs.builder()
                .name("Datacenter Example")
                .location("us/las")
                .description("Datacenter Description")
                .secAuthProtection(false)
                .build());
    
            var exampleIPBlock = new IPBlock("exampleIPBlock", IPBlockArgs.builder()
                .location("us/las")
                .size(2)
                .name("IP Block Example")
                .build());
    
            var exampleLan = new Lan("exampleLan", LanArgs.builder()
                .datacenterId(example.id())
                .public_(true)
                .name("Lan Example")
                .build());
    
            var exampleNatGateway = new NatGateway("exampleNatGateway", NatGatewayArgs.builder()
                .datacenterId(example.id())
                .name("example")
                .publicIps(            
                    exampleIPBlock.ips().applyValue(ips -> ips[0]),
                    exampleIPBlock.ips().applyValue(ips -> ips[1]))
                .lans(NatGatewayLanArgs.builder()
                    .id(exampleLan.id())
                    .gatewayIps("10.11.2.5")
                    .build())
                .build());
    
            var exampleNatGatewayRule = new NatGatewayRule("exampleNatGatewayRule", NatGatewayRuleArgs.builder()
                .datacenterId(example.id())
                .natgatewayId(exampleNatGateway.id())
                .name("example")
                .type("SNAT")
                .protocol("TCP")
                .sourceSubnet("10.0.1.0/24")
                .publicIp(exampleIPBlock.ips().applyValue(ips -> ips[0]))
                .targetSubnet("10.0.1.0/24")
                .targetPortRange(NatGatewayRuleTargetPortRangeArgs.builder()
                    .start(500)
                    .end(1000)
                    .build())
                .build());
    
        }
    }
    
    resources:
      example:
        type: ionoscloud:compute:Datacenter
        properties:
          name: Datacenter Example
          location: us/las
          description: Datacenter Description
          secAuthProtection: false
      exampleIPBlock:
        type: ionoscloud:compute:IPBlock
        name: example
        properties:
          location: us/las
          size: 2
          name: IP Block Example
      exampleLan:
        type: ionoscloud:compute:Lan
        name: example
        properties:
          datacenterId: ${example.id}
          public: true
          name: Lan Example
      exampleNatGateway:
        type: ionoscloud:compute:NatGateway
        name: example
        properties:
          datacenterId: ${example.id}
          name: example
          publicIps:
            - ${exampleIPBlock.ips[0]}
            - ${exampleIPBlock.ips[1]}
          lans:
            - id: ${exampleLan.id}
              gatewayIps:
                - 10.11.2.5
      exampleNatGatewayRule:
        type: ionoscloud:compute:NatGatewayRule
        name: example
        properties:
          datacenterId: ${example.id}
          natgatewayId: ${exampleNatGateway.id}
          name: example
          type: SNAT
          protocol: TCP
          sourceSubnet: 10.0.1.0/24
          publicIp: ${exampleIPBlock.ips[0]}
          targetSubnet: 10.0.1.0/24
          targetPortRange:
            start: 500
            end: 1000
    

    Create NatGatewayRule Resource

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

    Constructor syntax

    new NatGatewayRule(name: string, args: NatGatewayRuleArgs, opts?: CustomResourceOptions);
    @overload
    def NatGatewayRule(resource_name: str,
                       args: NatGatewayRuleArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def NatGatewayRule(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       datacenter_id: Optional[str] = None,
                       natgateway_id: Optional[str] = None,
                       public_ip: Optional[str] = None,
                       source_subnet: Optional[str] = None,
                       name: Optional[str] = None,
                       protocol: Optional[str] = None,
                       target_port_range: Optional[NatGatewayRuleTargetPortRangeArgs] = None,
                       target_subnet: Optional[str] = None,
                       type: Optional[str] = None)
    func NewNatGatewayRule(ctx *Context, name string, args NatGatewayRuleArgs, opts ...ResourceOption) (*NatGatewayRule, error)
    public NatGatewayRule(string name, NatGatewayRuleArgs args, CustomResourceOptions? opts = null)
    public NatGatewayRule(String name, NatGatewayRuleArgs args)
    public NatGatewayRule(String name, NatGatewayRuleArgs args, CustomResourceOptions options)
    
    type: ionoscloud:compute:NatGatewayRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args NatGatewayRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args NatGatewayRuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args NatGatewayRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args NatGatewayRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args NatGatewayRuleArgs
    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 natGatewayRuleResource = new Ionoscloud.Compute.NatGatewayRule("natGatewayRuleResource", new()
    {
        DatacenterId = "string",
        NatgatewayId = "string",
        PublicIp = "string",
        SourceSubnet = "string",
        Name = "string",
        Protocol = "string",
        TargetPortRange = new Ionoscloud.Compute.Inputs.NatGatewayRuleTargetPortRangeArgs
        {
            End = 0,
            Start = 0,
        },
        TargetSubnet = "string",
        Type = "string",
    });
    
    example, err := compute.NewNatGatewayRule(ctx, "natGatewayRuleResource", &compute.NatGatewayRuleArgs{
    	DatacenterId: pulumi.String("string"),
    	NatgatewayId: pulumi.String("string"),
    	PublicIp:     pulumi.String("string"),
    	SourceSubnet: pulumi.String("string"),
    	Name:         pulumi.String("string"),
    	Protocol:     pulumi.String("string"),
    	TargetPortRange: &compute.NatGatewayRuleTargetPortRangeArgs{
    		End:   pulumi.Int(0),
    		Start: pulumi.Int(0),
    	},
    	TargetSubnet: pulumi.String("string"),
    	Type:         pulumi.String("string"),
    })
    
    var natGatewayRuleResource = new NatGatewayRule("natGatewayRuleResource", NatGatewayRuleArgs.builder()
        .datacenterId("string")
        .natgatewayId("string")
        .publicIp("string")
        .sourceSubnet("string")
        .name("string")
        .protocol("string")
        .targetPortRange(NatGatewayRuleTargetPortRangeArgs.builder()
            .end(0)
            .start(0)
            .build())
        .targetSubnet("string")
        .type("string")
        .build());
    
    nat_gateway_rule_resource = ionoscloud.compute.NatGatewayRule("natGatewayRuleResource",
        datacenter_id="string",
        natgateway_id="string",
        public_ip="string",
        source_subnet="string",
        name="string",
        protocol="string",
        target_port_range={
            "end": 0,
            "start": 0,
        },
        target_subnet="string",
        type="string")
    
    const natGatewayRuleResource = new ionoscloud.compute.NatGatewayRule("natGatewayRuleResource", {
        datacenterId: "string",
        natgatewayId: "string",
        publicIp: "string",
        sourceSubnet: "string",
        name: "string",
        protocol: "string",
        targetPortRange: {
            end: 0,
            start: 0,
        },
        targetSubnet: "string",
        type: "string",
    });
    
    type: ionoscloud:compute:NatGatewayRule
    properties:
        datacenterId: string
        name: string
        natgatewayId: string
        protocol: string
        publicIp: string
        sourceSubnet: string
        targetPortRange:
            end: 0
            start: 0
        targetSubnet: string
        type: string
    

    NatGatewayRule 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 NatGatewayRule resource accepts the following input properties:

    DatacenterId string
    [string] A Datacenter's UUID.
    NatgatewayId string
    [string] Nat Gateway's UUID.
    PublicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    SourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    Name string
    [string] Name of the NAT gateway rule.
    Protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    TargetPortRange Ionoscloud.NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    TargetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    Type string
    [string] Type of the NAT gateway rule.
    DatacenterId string
    [string] A Datacenter's UUID.
    NatgatewayId string
    [string] Nat Gateway's UUID.
    PublicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    SourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    Name string
    [string] Name of the NAT gateway rule.
    Protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    TargetPortRange NatGatewayRuleTargetPortRangeArgs
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    TargetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    Type string
    [string] Type of the NAT gateway rule.
    datacenterId String
    [string] A Datacenter's UUID.
    natgatewayId String
    [string] Nat Gateway's UUID.
    publicIp String
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet String
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    name String
    [string] Name of the NAT gateway rule.
    protocol String
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    targetPortRange NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet String
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type String
    [string] Type of the NAT gateway rule.
    datacenterId string
    [string] A Datacenter's UUID.
    natgatewayId string
    [string] Nat Gateway's UUID.
    publicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    name string
    [string] Name of the NAT gateway rule.
    protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    targetPortRange NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type string
    [string] Type of the NAT gateway rule.
    datacenter_id str
    [string] A Datacenter's UUID.
    natgateway_id str
    [string] Nat Gateway's UUID.
    public_ip str
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    source_subnet str
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    name str
    [string] Name of the NAT gateway rule.
    protocol str
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    target_port_range NatGatewayRuleTargetPortRangeArgs
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    target_subnet str
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type str
    [string] Type of the NAT gateway rule.
    datacenterId String
    [string] A Datacenter's UUID.
    natgatewayId String
    [string] Nat Gateway's UUID.
    publicIp String
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet String
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    name String
    [string] Name of the NAT gateway rule.
    protocol String
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    targetPortRange Property Map
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet String
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type String
    [string] Type of the NAT gateway rule.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing NatGatewayRule Resource

    Get an existing NatGatewayRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: NatGatewayRuleState, opts?: CustomResourceOptions): NatGatewayRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datacenter_id: Optional[str] = None,
            name: Optional[str] = None,
            natgateway_id: Optional[str] = None,
            protocol: Optional[str] = None,
            public_ip: Optional[str] = None,
            source_subnet: Optional[str] = None,
            target_port_range: Optional[NatGatewayRuleTargetPortRangeArgs] = None,
            target_subnet: Optional[str] = None,
            type: Optional[str] = None) -> NatGatewayRule
    func GetNatGatewayRule(ctx *Context, name string, id IDInput, state *NatGatewayRuleState, opts ...ResourceOption) (*NatGatewayRule, error)
    public static NatGatewayRule Get(string name, Input<string> id, NatGatewayRuleState? state, CustomResourceOptions? opts = null)
    public static NatGatewayRule get(String name, Output<String> id, NatGatewayRuleState state, CustomResourceOptions options)
    resources:  _:    type: ionoscloud:compute:NatGatewayRule    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    DatacenterId string
    [string] A Datacenter's UUID.
    Name string
    [string] Name of the NAT gateway rule.
    NatgatewayId string
    [string] Nat Gateway's UUID.
    Protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    PublicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    SourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    TargetPortRange Ionoscloud.NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    TargetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    Type string
    [string] Type of the NAT gateway rule.
    DatacenterId string
    [string] A Datacenter's UUID.
    Name string
    [string] Name of the NAT gateway rule.
    NatgatewayId string
    [string] Nat Gateway's UUID.
    Protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    PublicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    SourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    TargetPortRange NatGatewayRuleTargetPortRangeArgs
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    TargetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    Type string
    [string] Type of the NAT gateway rule.
    datacenterId String
    [string] A Datacenter's UUID.
    name String
    [string] Name of the NAT gateway rule.
    natgatewayId String
    [string] Nat Gateway's UUID.
    protocol String
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    publicIp String
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet String
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    targetPortRange NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet String
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type String
    [string] Type of the NAT gateway rule.
    datacenterId string
    [string] A Datacenter's UUID.
    name string
    [string] Name of the NAT gateway rule.
    natgatewayId string
    [string] Nat Gateway's UUID.
    protocol string
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    publicIp string
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet string
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    targetPortRange NatGatewayRuleTargetPortRange
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet string
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type string
    [string] Type of the NAT gateway rule.
    datacenter_id str
    [string] A Datacenter's UUID.
    name str
    [string] Name of the NAT gateway rule.
    natgateway_id str
    [string] Nat Gateway's UUID.
    protocol str
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    public_ip str
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    source_subnet str
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    target_port_range NatGatewayRuleTargetPortRangeArgs
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    target_subnet str
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type str
    [string] Type of the NAT gateway rule.
    datacenterId String
    [string] A Datacenter's UUID.
    name String
    [string] Name of the NAT gateway rule.
    natgatewayId String
    [string] Nat Gateway's UUID.
    protocol String
    [string] Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
    publicIp String
    [string] Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource.
    sourceSubnet String
    [string] Source subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets source IP address.
    targetPortRange Property Map
    Target port range of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on destination port. If none is provided, rule will match any port.
    targetSubnet String
    [string] Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address.
    type String
    [string] Type of the NAT gateway rule.

    Supporting Types

    NatGatewayRuleTargetPortRange, NatGatewayRuleTargetPortRangeArgs

    End int
    [int] Target port range end associated with the NAT gateway rule.
    Start int
    [int] Target port range start associated with the NAT gateway rule.
    End int
    [int] Target port range end associated with the NAT gateway rule.
    Start int
    [int] Target port range start associated with the NAT gateway rule.
    end Integer
    [int] Target port range end associated with the NAT gateway rule.
    start Integer
    [int] Target port range start associated with the NAT gateway rule.
    end number
    [int] Target port range end associated with the NAT gateway rule.
    start number
    [int] Target port range start associated with the NAT gateway rule.
    end int
    [int] Target port range end associated with the NAT gateway rule.
    start int
    [int] Target port range start associated with the NAT gateway rule.
    end Number
    [int] Target port range end associated with the NAT gateway rule.
    start Number
    [int] Target port range start associated with the NAT gateway rule.

    Import

    A Nat Gateway Rule resource can be imported using its resource id, the datacenter id and the `natgateway id , e.g.

    $ pulumi import ionoscloud:compute/natGatewayRule:NatGatewayRule my_natgateway_rule datacenter uuid/nat gateway uuid/nat gateway rule uuid
    

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

    Package Details

    Repository
    ionoscloud ionos-cloud/pulumi-ionoscloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the ionoscloud Terraform Provider.
    ionoscloud logo
    IonosCloud v0.2.2 published on Monday, May 12, 2025 by ionos-cloud