1. Packages
  2. Ionoscloud Provider
  3. API Docs
  4. getNatgatewayRule
ionoscloud 6.7.6 published on Monday, Apr 14, 2025 by ionos-cloud

ionoscloud.getNatgatewayRule

Explore with Pulumi AI

The NAT Gateway Rule data source can be used to search for and return existing NAT Gateway Rules. If a single match is found, it will be returned. If your search results in multiple matches, an error will be returned. When this happens, please refine your search string so that it is specific enough to return only one result.

Example Usage

By ID

import * as pulumi from "@pulumi/pulumi";
import * as ionoscloud from "@pulumi/ionoscloud";

const example = ionoscloud.getNatgatewayRule({
    datacenterId: "datacenter_id",
    id: "natgateway_rule_id",
    natgatewayId: "natgateway_id",
});
Copy
import pulumi
import pulumi_ionoscloud as ionoscloud

example = ionoscloud.get_natgateway_rule(datacenter_id="datacenter_id",
    id="natgateway_rule_id",
    natgateway_id="natgateway_id")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ionoscloud.LookupNatgatewayRule(ctx, &ionoscloud.LookupNatgatewayRuleArgs{
			DatacenterId: "datacenter_id",
			Id:           pulumi.StringRef("natgateway_rule_id"),
			NatgatewayId: "natgateway_id",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ionoscloud = Pulumi.Ionoscloud;

return await Deployment.RunAsync(() => 
{
    var example = Ionoscloud.GetNatgatewayRule.Invoke(new()
    {
        DatacenterId = "datacenter_id",
        Id = "natgateway_rule_id",
        NatgatewayId = "natgateway_id",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ionoscloud.IonoscloudFunctions;
import com.pulumi.ionoscloud.inputs.GetNatgatewayRuleArgs;
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) {
        final var example = IonoscloudFunctions.getNatgatewayRule(GetNatgatewayRuleArgs.builder()
            .datacenterId("datacenter_id")
            .id("natgateway_rule_id")
            .natgatewayId("natgateway_id")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: ionoscloud:getNatgatewayRule
      arguments:
        datacenterId: datacenter_id
        id: natgateway_rule_id
        natgatewayId: natgateway_id
Copy

By Name

import * as pulumi from "@pulumi/pulumi";
import * as ionoscloud from "@pulumi/ionoscloud";

const example = ionoscloud.getNatgatewayRule({
    datacenterId: "datacenter_id",
    name: "NAT Gateway Rule Example",
    natgatewayId: "natgateway_id",
});
Copy
import pulumi
import pulumi_ionoscloud as ionoscloud

example = ionoscloud.get_natgateway_rule(datacenter_id="datacenter_id",
    name="NAT Gateway Rule Example",
    natgateway_id="natgateway_id")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ionoscloud/v6/ionoscloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ionoscloud.LookupNatgatewayRule(ctx, &ionoscloud.LookupNatgatewayRuleArgs{
			DatacenterId: "datacenter_id",
			Name:         pulumi.StringRef("NAT Gateway Rule Example"),
			NatgatewayId: "natgateway_id",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ionoscloud = Pulumi.Ionoscloud;

return await Deployment.RunAsync(() => 
{
    var example = Ionoscloud.GetNatgatewayRule.Invoke(new()
    {
        DatacenterId = "datacenter_id",
        Name = "NAT Gateway Rule Example",
        NatgatewayId = "natgateway_id",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ionoscloud.IonoscloudFunctions;
import com.pulumi.ionoscloud.inputs.GetNatgatewayRuleArgs;
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) {
        final var example = IonoscloudFunctions.getNatgatewayRule(GetNatgatewayRuleArgs.builder()
            .datacenterId("datacenter_id")
            .name("NAT Gateway Rule Example")
            .natgatewayId("natgateway_id")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: ionoscloud:getNatgatewayRule
      arguments:
        datacenterId: datacenter_id
        name: NAT Gateway Rule Example
        natgatewayId: natgateway_id
Copy

Using getNatgatewayRule

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getNatgatewayRule(args: GetNatgatewayRuleArgs, opts?: InvokeOptions): Promise<GetNatgatewayRuleResult>
function getNatgatewayRuleOutput(args: GetNatgatewayRuleOutputArgs, opts?: InvokeOptions): Output<GetNatgatewayRuleResult>
Copy
def get_natgateway_rule(datacenter_id: Optional[str] = None,
                        id: Optional[str] = None,
                        name: Optional[str] = None,
                        natgateway_id: Optional[str] = None,
                        timeouts: Optional[GetNatgatewayRuleTimeouts] = None,
                        opts: Optional[InvokeOptions] = None) -> GetNatgatewayRuleResult
def get_natgateway_rule_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                        id: Optional[pulumi.Input[str]] = None,
                        name: Optional[pulumi.Input[str]] = None,
                        natgateway_id: Optional[pulumi.Input[str]] = None,
                        timeouts: Optional[pulumi.Input[GetNatgatewayRuleTimeoutsArgs]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetNatgatewayRuleResult]
Copy
func LookupNatgatewayRule(ctx *Context, args *LookupNatgatewayRuleArgs, opts ...InvokeOption) (*LookupNatgatewayRuleResult, error)
func LookupNatgatewayRuleOutput(ctx *Context, args *LookupNatgatewayRuleOutputArgs, opts ...InvokeOption) LookupNatgatewayRuleResultOutput
Copy

> Note: This function is named LookupNatgatewayRule in the Go SDK.

public static class GetNatgatewayRule 
{
    public static Task<GetNatgatewayRuleResult> InvokeAsync(GetNatgatewayRuleArgs args, InvokeOptions? opts = null)
    public static Output<GetNatgatewayRuleResult> Invoke(GetNatgatewayRuleInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetNatgatewayRuleResult> getNatgatewayRule(GetNatgatewayRuleArgs args, InvokeOptions options)
public static Output<GetNatgatewayRuleResult> getNatgatewayRule(GetNatgatewayRuleArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: ionoscloud:index/getNatgatewayRule:getNatgatewayRule
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

DatacenterId This property is required. string
Datacenter's UUID.
NatgatewayId This property is required. string
Nat Gateway's UUID.
Id string

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

Name string
Name of an existing NAT gateway rule that you want to search for.
Timeouts GetNatgatewayRuleTimeouts
DatacenterId This property is required. string
Datacenter's UUID.
NatgatewayId This property is required. string
Nat Gateway's UUID.
Id string

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

Name string
Name of an existing NAT gateway rule that you want to search for.
Timeouts GetNatgatewayRuleTimeouts
datacenterId This property is required. String
Datacenter's UUID.
natgatewayId This property is required. String
Nat Gateway's UUID.
id String

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

name String
Name of an existing NAT gateway rule that you want to search for.
timeouts GetNatgatewayRuleTimeouts
datacenterId This property is required. string
Datacenter's UUID.
natgatewayId This property is required. string
Nat Gateway's UUID.
id string

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

name string
Name of an existing NAT gateway rule that you want to search for.
timeouts GetNatgatewayRuleTimeouts
datacenter_id This property is required. str
Datacenter's UUID.
natgateway_id This property is required. str
Nat Gateway's UUID.
id str

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

name str
Name of an existing NAT gateway rule that you want to search for.
timeouts GetNatgatewayRuleTimeouts
datacenterId This property is required. String
Datacenter's UUID.
natgatewayId This property is required. String
Nat Gateway's UUID.
id String

ID of the NAT gateway rule you want to search for.

Both datacenter_id and natgateway_id and either name or id must be provided. If none, or both of name and id are provided, the datasource will return an error.

name String
Name of an existing NAT gateway rule that you want to search for.
timeouts Property Map

getNatgatewayRule Result

The following output properties are available:

DatacenterId string
Id string
Id of the NAT gateway rule
Name string
Name of the NAT gateway rule
NatgatewayId string
Protocol string
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
PublicIp 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
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.
TargetPortRanges List<GetNatgatewayRuleTargetPortRange>
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
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
ype of the NAT gateway rule.
Timeouts GetNatgatewayRuleTimeouts
DatacenterId string
Id string
Id of the NAT gateway rule
Name string
Name of the NAT gateway rule
NatgatewayId string
Protocol string
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
PublicIp 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
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.
TargetPortRanges []GetNatgatewayRuleTargetPortRange
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
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
ype of the NAT gateway rule.
Timeouts GetNatgatewayRuleTimeouts
datacenterId String
id String
Id of the NAT gateway rule
name String
Name of the NAT gateway rule
natgatewayId String
protocol String
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
publicIp 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
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.
targetPortRanges List<GetNatgatewayRuleTargetPortRange>
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
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
ype of the NAT gateway rule.
timeouts GetNatgatewayRuleTimeouts
datacenterId string
id string
Id of the NAT gateway rule
name string
Name of the NAT gateway rule
natgatewayId string
protocol string
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
publicIp 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
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.
targetPortRanges GetNatgatewayRuleTargetPortRange[]
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
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
ype of the NAT gateway rule.
timeouts GetNatgatewayRuleTimeouts
datacenter_id str
id str
Id of the NAT gateway rule
name str
Name of the NAT gateway rule
natgateway_id str
protocol str
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
public_ip str
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
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_ranges Sequence[GetNatgatewayRuleTargetPortRange]
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
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
ype of the NAT gateway rule.
timeouts GetNatgatewayRuleTimeouts
datacenterId String
id String
Id of the NAT gateway rule
name String
Name of the NAT gateway rule
natgatewayId String
protocol String
Protocol of the NAT gateway rule. Defaults to ALL. If protocol is 'ICMP' then targetPortRange start and end cannot be set.
publicIp 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
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.
targetPortRanges List<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
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
ype of the NAT gateway rule.
timeouts Property Map

Supporting Types

GetNatgatewayRuleTargetPortRange

End This property is required. double
Start This property is required. double
End This property is required. float64
Start This property is required. float64
end This property is required. Double
start This property is required. Double
end This property is required. number
start This property is required. number
end This property is required. float
start This property is required. float
end This property is required. Number
start This property is required. Number

GetNatgatewayRuleTimeouts

Create string
Default string
Delete string
Update string
Create string
Default string
Delete string
Update string
create String
default_ String
delete String
update String
create string
default string
delete string
update string
create String
default String
delete String
update String

Package Details

Repository
ionoscloud ionos-cloud/terraform-provider-ionoscloud
License
Notes
This Pulumi package is based on the ionoscloud Terraform Provider.