8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

Terraform : Oracle Cloud Infrastructure (OCI) Virtual Cloud Network (VCN)

This article describes how to create a virtual cloud network (VCN) on Oracle Cloud Infrastructure (OCI) using Terraform.

I originally wrote this article using the oci_core_vcn resource, which was a lot simpler, but proved problematic on my free tier account, so I switched to using the VCN module, as described in the Oracle documentation. Thanks to Brian Spendolini and Torsten Kleiber for their help and advice.

Related articles.

Create Working Directory

Create a new working directory and switch to that directory.

mkdir \git\oraclebase\terraform\oci\oci_vcn
cd \git\oraclebase\terraform\oci\oci_vcn

In a previous article (here) we discussed the creation of an OCI provider. Copy the OCI provider information into this new working directory.

copy \git\oraclebase\terraform\oci\oci_provider\*.tf .
copy \git\oraclebase\terraform\oci\oci_provider\*.tfvars .

oci_vcn.tf

Create a file called "oci_vcn.tf" with the following contents.

# Variables
variable "compartment_id"   { type = string }
variable "vcn_display_name" { type = string }
variable "vcn_dns_label"    { type = string }

variable "vnc_cidr_block" {
  type    = string
  default = "10.0.0.0/16"
}

variable "vnc_private_subnet_cidr_block" {
  type    = string
  default = "10.0.1.0/24"
}

variable "vnc_public_subnet_cidr_block" {
  type    = string
  default = "10.0.0.0/24"
}


# Modules and Resources
module "vcn"{
  source                   = "oracle-terraform-modules/vcn/oci"
  version                  = "2.0.0"
  
  # Required
  compartment_id           = var.compartment_id
  region                   = var.region
  vcn_name                 = var.vcn_display_name
  vcn_dns_label            = var.vcn_dns_label

  # Optional
  internet_gateway_enabled = true
  # Commented out for my free tier account.
  #nat_gateway_enabled      = true
  #service_gateway_enabled  = true
  vcn_cidr                 = var.vnc_cidr_block
}

resource "oci_core_subnet" "tf_vcn_private_subnet"{
  # Required
  compartment_id    = var.compartment_id
  vcn_id            = module.vcn.vcn_id
  cidr_block        = var.vnc_private_subnet_cidr_block

  # Optional
  route_table_id    = module.vcn.nat_route_id
  security_list_ids = [oci_core_security_list.tf_private_security_list.id]
  display_name      = "private-subnet"
}

resource "oci_core_subnet" "tf_vcn_public_subnet"{
  # Required
  compartment_id    = var.compartment_id
  vcn_id            = module.vcn.vcn_id
  cidr_block        = var.vnc_public_subnet_cidr_block

  # Optional
  route_table_id    = module.vcn.ig_route_id
  security_list_ids = [oci_core_security_list.tf_public_security_list.id]
  display_name      = "public-subnet"
}

resource "oci_core_security_list" "tf_private_security_list"{
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id
  display_name   = "security-list-for-private-subnet"

  egress_security_rules {
    stateless        = false
    destination      = "0.0.0.0/0"
    destination_type = "CIDR_BLOCK"
    protocol         = "all" 
  }

  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"

    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
      min = 22
      max = 22
    }
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
      code = 4
    } 
  }   
  
  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
    } 
  }
}

resource "oci_core_security_list" "tf_public_security_list"{
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id
  display_name   = "security-list-for-public-subnet"

  egress_security_rules {
    stateless        = false
    destination      = "0.0.0.0/0"
    destination_type = "CIDR_BLOCK"
    protocol         = "all" 
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
        min = 22
        max = 22
    }
  }

  # Example of adding ports 1521-1522.
  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml TCP is 6
    protocol    = "6"
    tcp_options { 
        min = 1521
        max = 1522
    }
  }

  ingress_security_rules { 
    stateless   = false
    source      = "0.0.0.0/0"
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
      code = 4
    } 
  }   
  
  ingress_security_rules { 
    stateless   = false
    source      = var.vnc_cidr_block
    source_type = "CIDR_BLOCK"
    # Get protocol numbers from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml ICMP is 1  
    protocol    = "1"

    # For ICMP type and code see: https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
    icmp_options {
      type = 3
    } 
  }

}

resource "oci_core_dhcp_options" "tf_dhcp_options"{
  # Required
  compartment_id = var.compartment_id
  vcn_id         = module.vcn.vcn_id

  #Options for type are either "DomainNameServer" or "SearchDomain"
  options {
    type        = "DomainNameServer"  
    server_type = "VcnLocalPlusInternet"
  }
  
  # Optional
  display_name = "default-dhcp-options"
}


# Outputs
output "vcn_id" {
  value = module.vcn.vcn_id
}

output "private_security_list_id" {
  value = oci_core_security_list.tf_private_security_list.id
}

output "public_security_list_id" {
  value = oci_core_security_list.tf_public_security_list.id
}

output "private_subnet_id" {
  value = oci_core_subnet.tf_vcn_private_subnet.id
}

output "public_subnet_id" {
  value = oci_core_subnet.tf_vcn_public_subnet.id
}

The file begins with variable definitions. We could set default values for these variables, or use literal values directly in the provider definition, but we don't want sensitive information checked into version control, so it makes sense to separate out variable values from the script. The resources section defines the VCN, subnets and security lists using the input variables. Most of the definitions are defaults, but we've included an extra ingress rule for ports 1521-1522. The outputs section allows us to see information about the VCN, subnets and security lists that have been created, including the IDs.

The variables, resources and outputs sections can be split into separate files if you find that organisation easier. It may help for more complex definitions.

oci_vcn_variables.auto.tf

There are a number of ways to supply values for input variables. In this example we'll use a ".tfvars" file. We won't check this script into version control as it contains sensitive information.

Create a file called "oci_vcn_variables.auto.tfvars" with the following contents. Adjust the values to match your desired compartment details.

compartment_id   = "ocid1.compartment.oc1..aaaaaaaa..."
vcn_display_name = "obvcn2"
vcn_dns_label    = "obvcn2"

The compartment_id is the OCID of the compartment that will house the VCN. You must adjust it with a valid value from your Oracle Cloud account. You would not normally use the root compartment for this. You can get the ID of a compartment from your Oracle Cloud account as follows.

Build the OCI Virtual Cloud Network (VCN)

Initialize the working directory using the terraform init command.

terraform init

Use the terraform plan command to test the execution plan.

terraform plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # oci_core_dhcp_options.tf_dhcp_options will be created
  + resource "oci_core_dhcp_options" "tf_dhcp_options" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "default-dhcp-options"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + options {
          + custom_dns_servers  = []
          + search_domain_names = (known after apply)
          + server_type         = "VcnLocalPlusInternet"
          + type                = "DomainNameServer"
        }
    }

  # oci_core_security_list.tf_private_security_list will be created
  + resource "oci_core_security_list" "tf_private_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-private-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_security_list.tf_public_security_list will be created
  + resource "oci_core_security_list" "tf_public_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-public-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 1522
              + min = 1521
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_subnet.tf_vcn_private_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_private_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.1.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "private-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # oci_core_subnet.tf_vcn_public_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_public_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.0.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "public-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # module.vcn.oci_core_internet_gateway.ig[0] will be created
  + resource "oci_core_internet_gateway" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-gateway"
      + enabled        = true
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # module.vcn.oci_core_route_table.ig[0] will be created
  + resource "oci_core_route_table" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-route"
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + route_rules {
          + cidr_block        = (known after apply)
          + description       = (known after apply)
          + destination       = "0.0.0.0/0"
          + destination_type  = (known after apply)
          + network_entity_id = (known after apply)
        }
    }

  # module.vcn.oci_core_vcn.vcn will be created
  + resource "oci_core_vcn" "vcn" {
      + cidr_block               = "10.0.0.0/16"
      + cidr_blocks              = (known after apply)
      + compartment_id           = "ocid1.compartment.oc1..aaaaaaaa..."
      + default_dhcp_options_id  = (known after apply)
      + default_route_table_id   = (known after apply)
      + default_security_list_id = (known after apply)
      + defined_tags             = (known after apply)
      + display_name             = "obvcn2"
      + dns_label                = "obvcn2"
      + freeform_tags            = {
          + "environment" = "dev"
        }
      + id                       = (known after apply)
      + ipv6cidr_block           = (known after apply)
      + ipv6public_cidr_block    = (known after apply)
      + is_ipv6enabled           = (known after apply)
      + state                    = (known after apply)
      + time_created             = (known after apply)
      + vcn_domain_name          = (known after apply)
    }

Plan: 8 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + private_security_list_id = (known after apply)
  + private_subnet_id        = (known after apply)
  + public_security_list_id  = (known after apply)
  + public_subnet_id         = (known after apply)
  + vcn_id                   = (known after apply)

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

Use the terraform apply command to create the OCI compartment.

terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # oci_core_dhcp_options.tf_dhcp_options will be created
  + resource "oci_core_dhcp_options" "tf_dhcp_options" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "default-dhcp-options"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + options {
          + custom_dns_servers  = []
          + search_domain_names = (known after apply)
          + server_type         = "VcnLocalPlusInternet"
          + type                = "DomainNameServer"
        }
    }

  # oci_core_security_list.tf_private_security_list will be created
  + resource "oci_core_security_list" "tf_private_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-private-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_security_list.tf_public_security_list will be created
  + resource "oci_core_security_list" "tf_public_security_list" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "security-list-for-public-subnet"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + egress_security_rules {
          + description      = (known after apply)
          + destination      = "0.0.0.0/0"
          + destination_type = "CIDR_BLOCK"
          + protocol         = "all"
          + stateless        = false
        }

      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "10.0.0.0/16"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = -1
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "1"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + icmp_options {
              + code = 4
              + type = 3
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 1522
              + min = 1521
            }
        }
      + ingress_security_rules {
          + description = (known after apply)
          + protocol    = "6"
          + source      = "0.0.0.0/0"
          + source_type = "CIDR_BLOCK"
          + stateless   = false

          + tcp_options {
              + max = 22
              + min = 22
            }
        }
    }

  # oci_core_subnet.tf_vcn_private_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_private_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.1.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "private-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # oci_core_subnet.tf_vcn_public_subnet will be created
  + resource "oci_core_subnet" "tf_vcn_public_subnet" {
      + availability_domain        = (known after apply)
      + cidr_block                 = "10.0.0.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "public-subnet"
      + dns_label                  = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + ipv6cidr_block             = (known after apply)
      + ipv6public_cidr_block      = (known after apply)
      + ipv6virtual_router_ip      = (known after apply)
      + prohibit_public_ip_on_vnic = (known after apply)
      + route_table_id             = (known after apply)
      + security_list_ids          = (known after apply)
      + state                      = (known after apply)
      + subnet_domain_name         = (known after apply)
      + time_created               = (known after apply)
      + vcn_id                     = (known after apply)
      + virtual_router_ip          = (known after apply)
      + virtual_router_mac         = (known after apply)
    }

  # module.vcn.oci_core_internet_gateway.ig[0] will be created
  + resource "oci_core_internet_gateway" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-gateway"
      + enabled        = true
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # module.vcn.oci_core_route_table.ig[0] will be created
  + resource "oci_core_route_table" "ig" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaa..."
      + defined_tags   = (known after apply)
      + display_name   = "internet-route"
      + freeform_tags  = {
          + "environment" = "dev"
        }
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + route_rules {
          + cidr_block        = (known after apply)
          + description       = (known after apply)
          + destination       = "0.0.0.0/0"
          + destination_type  = (known after apply)
          + network_entity_id = (known after apply)
        }
    }

  # module.vcn.oci_core_vcn.vcn will be created
  + resource "oci_core_vcn" "vcn" {
      + cidr_block               = "10.0.0.0/16"
      + cidr_blocks              = (known after apply)
      + compartment_id           = "ocid1.compartment.oc1..aaaaaaaa..."
      + default_dhcp_options_id  = (known after apply)
      + default_route_table_id   = (known after apply)
      + default_security_list_id = (known after apply)
      + defined_tags             = (known after apply)
      + display_name             = "obvcn2"
      + dns_label                = "obvcn2"
      + freeform_tags            = {
          + "environment" = "dev"
        }
      + id                       = (known after apply)
      + ipv6cidr_block           = (known after apply)
      + ipv6public_cidr_block    = (known after apply)
      + is_ipv6enabled           = (known after apply)
      + state                    = (known after apply)
      + time_created             = (known after apply)
      + vcn_domain_name          = (known after apply)
    }

Plan: 8 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + private_security_list_id = (known after apply)
  + private_subnet_id        = (known after apply)
  + public_security_list_id  = (known after apply)
  + public_subnet_id         = (known after apply)
  + vcn_id                   = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.vcn.oci_core_vcn.vcn: Creating...
module.vcn.oci_core_vcn.vcn: Creation complete after 1s [id=ocid1.vcn.oc1.uk-london-1.amaaaaaa...]
module.vcn.oci_core_internet_gateway.ig[0]: Creating...
oci_core_dhcp_options.tf_dhcp_options: Creating...
oci_core_security_list.tf_private_security_list: Creating...
oci_core_security_list.tf_public_security_list: Creating...
module.vcn.oci_core_internet_gateway.ig[0]: Creation complete after 0s [id=ocid1.internetgateway.oc1.uk-london-1.aaaaaaaaa...]
module.vcn.oci_core_route_table.ig[0]: Creating...
oci_core_security_list.tf_private_security_list: Creation complete after 1s [id=ocid1.securitylist.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_private_subnet: Creating...
oci_core_security_list.tf_public_security_list: Creation complete after 1s [id=ocid1.securitylist.oc1.uk-london-1.aaaaaaaa...]
oci_core_dhcp_options.tf_dhcp_options: Creation complete after 1s [id=ocid1.dhcpoptions.oc1.uk-london-1.aaaaaaaa...]
module.vcn.oci_core_route_table.ig[0]: Creation complete after 1s [id=ocid1.routetable.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_public_subnet: Creating...
oci_core_subnet.tf_vcn_private_subnet: Creation complete after 3s [id=ocid1.subnet.oc1.uk-london-1.aaaaaaaa...]
oci_core_subnet.tf_vcn_public_subnet: Creation complete after 4s [id=ocid1.subnet.oc1.uk-london-1.aaaaaaaag...]

Apply complete! Resources: 8 added, 0 changed, 0 destroyed.

Outputs:

private_security_list_id = "ocid1.securitylist.oc1.uk-london-1.aaaaaaaa..."
private_subnet_id = "ocid1.subnet.oc1.uk-london-1.aaaaaaaa..."
public_security_list_id = "ocid1.securitylist.oc1.uk-london-1.aaaaaaaa..."
public_subnet_id = "ocid1.subnet.oc1.uk-london-1.aaaaaaaa..."
vcn_id = "ocid1.vcn.oc1.uk-london-1.amaaaaaa..."

Check the Oracle Cloud account to see the new VCN in the compartment you chose.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.