Oracle Cloud Infrastructure v3.9.0 published on Wednesday, Sep 24, 2025 by Pulumi
oci.Core.getSubnet
This data source provides details about a specific Subnet resource in Oracle Cloud Infrastructure Core service.
Gets the specified subnet’s information.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as oci from "@pulumi/oci";
const testSubnet = oci.Core.getSubnet({
    subnetId: testSubnetOciCoreSubnet.id,
});
import pulumi
import pulumi_oci as oci
test_subnet = oci.Core.get_subnet(subnet_id=test_subnet_oci_core_subnet["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.GetSubnet(ctx, &core.GetSubnetArgs{
			SubnetId: testSubnetOciCoreSubnet.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 testSubnet = Oci.Core.GetSubnet.Invoke(new()
    {
        SubnetId = testSubnetOciCoreSubnet.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.GetSubnetArgs;
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 testSubnet = CoreFunctions.getSubnet(GetSubnetArgs.builder()
            .subnetId(testSubnetOciCoreSubnet.id())
            .build());
    }
}
variables:
  testSubnet:
    fn::invoke:
      function: oci:Core:getSubnet
      arguments:
        subnetId: ${testSubnetOciCoreSubnet.id}
Using getSubnet
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 getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>def get_subnet(subnet_id: Optional[str] = None,
               opts: Optional[InvokeOptions] = None) -> GetSubnetResult
def get_subnet_output(subnet_id: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput> Note: This function is named LookupSubnet in the Go SDK.
public static class GetSubnet 
{
    public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
    public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
fn::invoke:
  function: oci:Core/getSubnet:getSubnet
  arguments:
    # arguments dictionaryThe following arguments are supported:
getSubnet Result
The following output properties are available:
- AvailabilityDomain string
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- CidrBlock string
- The subnet's CIDR block. Example: 10.0.1.0/24
- CompartmentId string
- The OCID of the compartment containing the subnet.
- 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"}
- DhcpOptions stringId 
- The OCID of the set of DHCP options that the subnet uses.
- DisplayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- DnsLabel string
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- 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 subnet's Oracle ID (OCID).
- Ipv6cidrBlock string
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- Ipv6cidrBlocks List<string>
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- Ipv6virtualRouter stringIp 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- ProhibitInternet boolIngress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- ProhibitPublic boolIp On Vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- RouteTable stringId 
- The OCID of the route table that the subnet uses.
- SecurityList List<string>Ids 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- State string
- The subnet's current state.
- SubnetDomain stringName 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- SubnetId string
- TimeCreated string
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- VcnId string
- The OCID of the VCN the subnet is in.
- VirtualRouter stringIp 
- The IP address of the virtual router. Example: 10.0.14.1
- VirtualRouter stringMac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
- AvailabilityDomain string
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- CidrBlock string
- The subnet's CIDR block. Example: 10.0.1.0/24
- CompartmentId string
- The OCID of the compartment containing the subnet.
- 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"}
- DhcpOptions stringId 
- The OCID of the set of DHCP options that the subnet uses.
- DisplayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- DnsLabel string
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- 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 subnet's Oracle ID (OCID).
- Ipv6cidrBlock string
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- Ipv6cidrBlocks []string
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- Ipv6virtualRouter stringIp 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- ProhibitInternet boolIngress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- ProhibitPublic boolIp On Vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- RouteTable stringId 
- The OCID of the route table that the subnet uses.
- SecurityList []stringIds 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- State string
- The subnet's current state.
- SubnetDomain stringName 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- SubnetId string
- TimeCreated string
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- VcnId string
- The OCID of the VCN the subnet is in.
- VirtualRouter stringIp 
- The IP address of the virtual router. Example: 10.0.14.1
- VirtualRouter stringMac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
- availabilityDomain String
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- cidrBlock String
- The subnet's CIDR block. Example: 10.0.1.0/24
- compartmentId String
- The OCID of the compartment containing the subnet.
- 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"}
- dhcpOptions StringId 
- The OCID of the set of DHCP options that the subnet uses.
- displayName String
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- dnsLabel String
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- 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 subnet's Oracle ID (OCID).
- ipv6cidrBlock String
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- ipv6cidrBlocks List<String>
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- ipv6virtualRouter StringIp 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- prohibitInternet BooleanIngress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- prohibitPublic BooleanIp On Vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- routeTable StringId 
- The OCID of the route table that the subnet uses.
- securityList List<String>Ids 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- state String
- The subnet's current state.
- subnetDomain StringName 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- subnetId String
- timeCreated String
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId String
- The OCID of the VCN the subnet is in.
- virtualRouter StringIp 
- The IP address of the virtual router. Example: 10.0.14.1
- virtualRouter StringMac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
- availabilityDomain string
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- cidrBlock string
- The subnet's CIDR block. Example: 10.0.1.0/24
- compartmentId string
- The OCID of the compartment containing the subnet.
- {[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"}
- dhcpOptions stringId 
- The OCID of the set of DHCP options that the subnet uses.
- displayName string
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- dnsLabel string
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- {[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 subnet's Oracle ID (OCID).
- ipv6cidrBlock string
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- ipv6cidrBlocks string[]
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- ipv6virtualRouter stringIp 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- prohibitInternet booleanIngress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- prohibitPublic booleanIp On Vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- routeTable stringId 
- The OCID of the route table that the subnet uses.
- securityList string[]Ids 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- state string
- The subnet's current state.
- subnetDomain stringName 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- subnetId string
- timeCreated string
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId string
- The OCID of the VCN the subnet is in.
- virtualRouter stringIp 
- The IP address of the virtual router. Example: 10.0.14.1
- virtualRouter stringMac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
- availability_domain str
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- cidr_block str
- The subnet's CIDR block. Example: 10.0.1.0/24
- compartment_id str
- The OCID of the compartment containing the subnet.
- 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"}
- dhcp_options_ strid 
- The OCID of the set of DHCP options that the subnet uses.
- display_name str
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- dns_label str
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- 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 subnet's Oracle ID (OCID).
- ipv6cidr_block str
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- ipv6cidr_blocks Sequence[str]
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- ipv6virtual_router_ strip 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- prohibit_internet_ boolingress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- prohibit_public_ boolip_ on_ vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- route_table_ strid 
- The OCID of the route table that the subnet uses.
- security_list_ Sequence[str]ids 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- state str
- The subnet's current state.
- subnet_domain_ strname 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- subnet_id str
- time_created str
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcn_id str
- The OCID of the VCN the subnet is in.
- virtual_router_ strip 
- The IP address of the virtual router. Example: 10.0.14.1
- virtual_router_ strmac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
- availabilityDomain String
- The subnet's availability domain. This attribute will be null if this is a regional subnet instead of an AD-specific subnet. Oracle recommends creating regional subnets. Example: Uocm:PHX-AD-1
- cidrBlock String
- The subnet's CIDR block. Example: 10.0.1.0/24
- compartmentId String
- The OCID of the compartment containing the subnet.
- 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"}
- dhcpOptions StringId 
- The OCID of the set of DHCP options that the subnet uses.
- displayName String
- A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
- dnsLabel String
- A DNS label for the subnet, used in conjunction with the VNIC's hostname and VCN's DNS label to form a fully qualified domain name (FQDN) for each VNIC within this subnet (for example, bminstance1.subnet123.vcn1.oraclevcn.com). Must be an alphanumeric string that begins with a letter and is unique within the VCN. The value cannot be changed.
- 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 subnet's Oracle ID (OCID).
- ipv6cidrBlock String
- For an IPv6-enabled subnet, this is the IPv6 prefix for the subnet's IP address space. The subnet size is always /64. See IPv6 Addresses. Example: 2001:0db8:0123:1111::/64
- ipv6cidrBlocks List<String>
- The list of all IPv6 prefixes (Oracle allocated IPv6 GUA, ULA or private IPv6 prefixes, BYOIPv6 prefixes) for the subnet.
- ipv6virtualRouter StringIp 
- For an IPv6-enabled subnet, this is the IPv6 address of the virtual router. Example: 2001:0db8:0123:1111:89ab:cdef:1234:5678
- prohibitInternet BooleanIngress 
- Whether to disallow ingress internet traffic to VNICs within this subnet. Defaults to false.
- prohibitPublic BooleanIp On Vnic 
- Whether VNICs within this subnet can have public IP addresses. Defaults to false, which means VNICs created in this subnet will automatically be assigned public IP addresses unless specified otherwise during instance launch or VNIC creation (with the assignPublicIpflag in CreateVnicDetails). IfprohibitPublicIpOnVnicis set to true, VNICs created in this subnet cannot have public IP addresses (that is, it's a private subnet). Example:true
- routeTable StringId 
- The OCID of the route table that the subnet uses.
- securityList List<String>Ids 
- The OCIDs of the security list or lists that the subnet uses. Remember that security lists are associated with the subnet, but the rules are applied to the individual VNICs in the subnet.
- state String
- The subnet's current state.
- subnetDomain StringName 
- The subnet's domain name, which consists of the subnet's DNS label, the VCN's DNS label, and the oraclevcn.comdomain.
- subnetId String
- timeCreated String
- The date and time the subnet was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- vcnId String
- The OCID of the VCN the subnet is in.
- virtualRouter StringIp 
- The IP address of the virtual router. Example: 10.0.14.1
- virtualRouter StringMac 
- The MAC address of the virtual router. Example: 00:00:00:00:00:01
Package Details
- Repository
- oci pulumi/pulumi-oci
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the ociTerraform Provider.
