Oracle Cloud Infrastructure v3.9.0 published on Wednesday, Sep 24, 2025 by Pulumi
oci.Core.getNatGateways
This data source provides the list of Nat Gateways in Oracle Cloud Infrastructure Core service.
Lists the NAT gateways in the specified compartment. You may optionally specify a VCN OCID to filter the results by VCN.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as oci from "@pulumi/oci";
const testNatGateways = oci.Core.getNatGateways({
    compartmentId: compartmentId,
    displayName: natGatewayDisplayName,
    state: natGatewayState,
    vcnId: testVcn.id,
});
import pulumi
import pulumi_oci as oci
test_nat_gateways = oci.Core.get_nat_gateways(compartment_id=compartment_id,
    display_name=nat_gateway_display_name,
    state=nat_gateway_state,
    vcn_id=test_vcn["id"])
package main
import (
	"github.com/pulumi/pulumi-oci/sdk/v3/go/oci/core"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := core.GetNatGateways(ctx, &core.GetNatGatewaysArgs{
			CompartmentId: compartmentId,
			DisplayName:   pulumi.StringRef(natGatewayDisplayName),
			State:         pulumi.StringRef(natGatewayState),
			VcnId:         pulumi.StringRef(testVcn.Id),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Oci = Pulumi.Oci;
return await Deployment.RunAsync(() => 
{
    var testNatGateways = Oci.Core.GetNatGateways.Invoke(new()
    {
        CompartmentId = compartmentId,
        DisplayName = natGatewayDisplayName,
        State = natGatewayState,
        VcnId = testVcn.Id,
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.oci.Core.CoreFunctions;
import com.pulumi.oci.Core.inputs.GetNatGatewaysArgs;
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 testNatGateways = CoreFunctions.getNatGateways(GetNatGatewaysArgs.builder()
            .compartmentId(compartmentId)
            .displayName(natGatewayDisplayName)
            .state(natGatewayState)
            .vcnId(testVcn.id())
            .build());
    }
}
variables:
  testNatGateways:
    fn::invoke:
      function: oci:Core:getNatGateways
      arguments:
        compartmentId: ${compartmentId}
        displayName: ${natGatewayDisplayName}
        state: ${natGatewayState}
        vcnId: ${testVcn.id}
Using getNatGateways
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 getNatGateways(args: GetNatGatewaysArgs, opts?: InvokeOptions): Promise<GetNatGatewaysResult>
function getNatGatewaysOutput(args: GetNatGatewaysOutputArgs, opts?: InvokeOptions): Output<GetNatGatewaysResult>def get_nat_gateways(compartment_id: Optional[str] = None,
                     display_name: Optional[str] = None,
                     filters: Optional[Sequence[GetNatGatewaysFilter]] = None,
                     state: Optional[str] = None,
                     vcn_id: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetNatGatewaysResult
def get_nat_gateways_output(compartment_id: Optional[pulumi.Input[str]] = None,
                     display_name: Optional[pulumi.Input[str]] = None,
                     filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetNatGatewaysFilterArgs]]]] = None,
                     state: Optional[pulumi.Input[str]] = None,
                     vcn_id: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetNatGatewaysResult]func GetNatGateways(ctx *Context, args *GetNatGatewaysArgs, opts ...InvokeOption) (*GetNatGatewaysResult, error)
func GetNatGatewaysOutput(ctx *Context, args *GetNatGatewaysOutputArgs, opts ...InvokeOption) GetNatGatewaysResultOutput> Note: This function is named GetNatGateways in the Go SDK.
public static class GetNatGateways 
{
    public static Task<GetNatGatewaysResult> InvokeAsync(GetNatGatewaysArgs args, InvokeOptions? opts = null)
    public static Output<GetNatGatewaysResult> Invoke(GetNatGatewaysInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetNatGatewaysResult> getNatGateways(GetNatGatewaysArgs args, InvokeOptions options)
public static Output<GetNatGatewaysResult> getNatGateways(GetNatGatewaysArgs args, InvokeOptions options)
fn::invoke:
  function: oci:Core/getNatGateways:getNatGateways
  arguments:
    # arguments dictionaryThe following arguments are supported:
- CompartmentId string
- The OCID of the compartment.
- DisplayName string
- A filter to return only resources that match the given display name exactly.
- Filters
List<GetNat Gateways Filter> 
- State string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- VcnId string
- The OCID of the VCN.
- CompartmentId string
- The OCID of the compartment.
- DisplayName string
- A filter to return only resources that match the given display name exactly.
- Filters
[]GetNat Gateways Filter 
- State string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- VcnId string
- The OCID of the VCN.
- compartmentId String
- The OCID of the compartment.
- displayName String
- A filter to return only resources that match the given display name exactly.
- filters
List<GetNat Gateways Filter> 
- state String
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- vcnId String
- The OCID of the VCN.
- compartmentId string
- The OCID of the compartment.
- displayName string
- A filter to return only resources that match the given display name exactly.
- filters
GetNat Gateways Filter[] 
- state string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- vcnId string
- The OCID of the VCN.
- compartment_id str
- The OCID of the compartment.
- display_name str
- A filter to return only resources that match the given display name exactly.
- filters
Sequence[GetNat Gateways Filter] 
- state str
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- vcn_id str
- The OCID of the VCN.
- compartmentId String
- The OCID of the compartment.
- displayName String
- A filter to return only resources that match the given display name exactly.
- filters List<Property Map>
- state String
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- vcnId String
- The OCID of the VCN.
getNatGateways Result
The following output properties are available:
- CompartmentId string
- The OCID of the compartment that contains the NAT gateway.
- Id string
- The provider-assigned unique ID for this managed resource.
- NatGateways List<GetNat Gateways Nat Gateway> 
- The list of nat_gateways.
- DisplayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- Filters
List<GetNat Gateways Filter> 
- State string
- The NAT gateway's current state.
- VcnId string
- The OCID of the VCN the NAT gateway belongs to.
- CompartmentId string
- The OCID of the compartment that contains the NAT gateway.
- Id string
- The provider-assigned unique ID for this managed resource.
- NatGateways []GetNat Gateways Nat Gateway 
- The list of nat_gateways.
- DisplayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- Filters
[]GetNat Gateways Filter 
- State string
- The NAT gateway's current state.
- VcnId string
- The OCID of the VCN the NAT gateway belongs to.
- compartmentId String
- The OCID of the compartment that contains the NAT gateway.
- id String
- The provider-assigned unique ID for this managed resource.
- natGateways List<GetNat Gateways Nat Gateway> 
- The list of nat_gateways.
- displayName String
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- filters
List<GetNat Gateways Filter> 
- state String
- The NAT gateway's current state.
- vcnId String
- The OCID of the VCN the NAT gateway belongs to.
- compartmentId string
- The OCID of the compartment that contains the NAT gateway.
- id string
- The provider-assigned unique ID for this managed resource.
- natGateways GetNat Gateways Nat Gateway[] 
- The list of nat_gateways.
- displayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- filters
GetNat Gateways Filter[] 
- state string
- The NAT gateway's current state.
- vcnId string
- The OCID of the VCN the NAT gateway belongs to.
- compartment_id str
- The OCID of the compartment that contains the NAT gateway.
- id str
- The provider-assigned unique ID for this managed resource.
- nat_gateways Sequence[GetNat Gateways Nat Gateway] 
- The list of nat_gateways.
- display_name str
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- filters
Sequence[GetNat Gateways Filter] 
- state str
- The NAT gateway's current state.
- vcn_id str
- The OCID of the VCN the NAT gateway belongs to.
- compartmentId String
- The OCID of the compartment that contains the NAT gateway.
- id String
- The provider-assigned unique ID for this managed resource.
- natGateways List<Property Map>
- The list of nat_gateways.
- displayName String
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- filters List<Property Map>
- state String
- The NAT gateway's current state.
- vcnId String
- The OCID of the VCN the NAT gateway belongs to.
Supporting Types
GetNatGatewaysFilter   
GetNatGatewaysNatGateway    
- BlockTraffic bool
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- CompartmentId string
- The OCID of the compartment.
- Dictionary<string, string>
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- DisplayName string
- A filter to return only resources that match the given display name exactly.
- Dictionary<string, string>
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- Id string
- The OCID of the NAT gateway.
- NatIp string
- The IP address associated with the NAT gateway.
- PublicIp stringId 
- The OCID of the public IP address associated with the NAT gateway.
- RouteTable stringId 
- The OCID of the route table used by the NAT gateway.
- State string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- TimeCreated string
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- VcnId string
- The OCID of the VCN.
- BlockTraffic bool
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- CompartmentId string
- The OCID of the compartment.
- map[string]string
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- DisplayName string
- A filter to return only resources that match the given display name exactly.
- map[string]string
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- Id string
- The OCID of the NAT gateway.
- NatIp string
- The IP address associated with the NAT gateway.
- PublicIp stringId 
- The OCID of the public IP address associated with the NAT gateway.
- RouteTable stringId 
- The OCID of the route table used by the NAT gateway.
- State string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- TimeCreated string
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- VcnId string
- The OCID of the VCN.
- blockTraffic Boolean
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- compartmentId String
- The OCID of the compartment.
- Map<String,String>
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- displayName String
- A filter to return only resources that match the given display name exactly.
- Map<String,String>
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- id String
- The OCID of the NAT gateway.
- natIp String
- The IP address associated with the NAT gateway.
- publicIp StringId 
- The OCID of the public IP address associated with the NAT gateway.
- routeTable StringId 
- The OCID of the route table used by the NAT gateway.
- state String
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- timeCreated String
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId String
- The OCID of the VCN.
- blockTraffic boolean
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- compartmentId string
- The OCID of the compartment.
- {[key: string]: string}
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- displayName string
- A filter to return only resources that match the given display name exactly.
- {[key: string]: string}
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- id string
- The OCID of the NAT gateway.
- natIp string
- The IP address associated with the NAT gateway.
- publicIp stringId 
- The OCID of the public IP address associated with the NAT gateway.
- routeTable stringId 
- The OCID of the route table used by the NAT gateway.
- state string
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- timeCreated string
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId string
- The OCID of the VCN.
- block_traffic bool
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- compartment_id str
- The OCID of the compartment.
- Mapping[str, str]
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- display_name str
- A filter to return only resources that match the given display name exactly.
- Mapping[str, str]
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- id str
- The OCID of the NAT gateway.
- nat_ip str
- The IP address associated with the NAT gateway.
- public_ip_ strid 
- The OCID of the public IP address associated with the NAT gateway.
- route_table_ strid 
- The OCID of the route table used by the NAT gateway.
- state str
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- time_created str
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcn_id str
- The OCID of the VCN.
- blockTraffic Boolean
- Whether the NAT gateway blocks traffic through it. The default is false. Example:true
- compartmentId String
- The OCID of the compartment.
- Map<String>
- Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
- displayName String
- A filter to return only resources that match the given display name exactly.
- Map<String>
- Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
- id String
- The OCID of the NAT gateway.
- natIp String
- The IP address associated with the NAT gateway.
- publicIp StringId 
- The OCID of the public IP address associated with the NAT gateway.
- routeTable StringId 
- The OCID of the route table used by the NAT gateway.
- state String
- A filter to return only resources that match the specified lifecycle state. The value is case insensitive.
- timeCreated String
- The date and time the NAT gateway was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId String
- The OCID of the VCN.
Package Details
- Repository
- oci pulumi/pulumi-oci
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the ociTerraform Provider.
