oci_core_subnet

This resource provides the Subnet resource in Oracle Cloud Infrastructure Core service.

Creates a new subnet in the specified VCN. You can’t change the size of the subnet after creation, so it’s important to think about the size of subnets you need before creating them. For more information, see VCNs and Subnets. For information on the number of subnets you can have in a VCN, see Service Limits.

For the purposes of access control, you must provide the OCID of the compartment where you want the subnet to reside. Notice that the subnet doesn’t have to be in the same compartment as the VCN, route tables, or other Networking Service components. If you’re not sure which compartment to use, put the subnet in the same compartment as the VCN. For more information about compartments and access control, see Overview of the IAM Service. For information about OCIDs, see Resource Identifiers.

You may optionally associate a route table with the subnet. If you don’t, the subnet will use the VCN’s default route table. For more information about route tables, see Route Tables.

You may optionally associate a security list with the subnet. If you don’t, the subnet will use the VCN’s default security list. For more information about security lists, see Security Lists.

You may optionally associate a set of DHCP options with the subnet. If you don’t, the subnet will use the VCN’s default set. For more information about DHCP options, see DHCP Options.

You may optionally specify a display name for the subnet, otherwise a default is provided. It does not have to be unique, and you can change it. Avoid entering confidential information.

You can also add a DNS label for the subnet, which is required if you want the Internet and VCN Resolver to resolve hostnames for instances in the subnet. For more information, see DNS in Your Virtual Cloud Network.

Example Usage

resource "oci_core_subnet" "test_subnet" {
	#Required
	cidr_block = var.subnet_cidr_block
	compartment_id = var.compartment_id
	vcn_id = oci_core_vcn.test_vcn.id

	#Optional
	availability_domain = var.subnet_availability_domain
	defined_tags = {"Operations.CostCenter"= "42"}
	dhcp_options_id = oci_core_dhcp_options.test_dhcp_options.id
	display_name = var.subnet_display_name
	dns_label = var.subnet_dns_label
	freeform_tags = {"Department"= "Finance"}
	ipv6cidr_block = var.subnet_ipv6cidr_block
	ipv6cidr_blocks = var.subnet_ipv6cidr_blocks
	prohibit_internet_ingress = var.subnet_prohibit_internet_ingress
	prohibit_public_ip_on_vnic = var.subnet_prohibit_public_ip_on_vnic
	route_table_id = oci_core_route_table.test_route_table.id
	security_list_ids = var.subnet_security_list_ids
}

Argument Reference

The following arguments are supported:

** IMPORTANT ** Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 20 minutes), when creating the Subnet * update - (Defaults to 20 minutes), when updating the Subnet * delete - (Defaults to 20 minutes), when destroying the Subnet

Import

Subnets can be imported using the id, e.g.

$ terraform import oci_core_subnet.test_subnet "id"