Creating an Instance with New VNC Network

Mastering Terraform on Oracle Cloud Infrastructure – Deep dive training

Table of Content

Creating an Instance with a New VNC Network

Here we would need 2 files in a folder they are listed below

  1. variables.tf
  2. vnic.tf

variables.tf

You can get these variable values from our previous exercise

#*************************************
#           TF Requirements
#*************************************
variable "tenancy_ocid" {
  default = "ocid1.tenancy.oc1..aaaaaaaaXXXXX5vjqpsdd6ahdouq"
}
variable "region" {
  default = "us-ashburn-1"
}
variable "user_ocid" {
  default = "ocid1.user.oc1..aaaaaaaa7XXXXfcue4nbuxjsf3s4mca"
}
variable "private_key_path"{
  default = "/Users/madhusudhanrao/tf/keys/myopensslkey.pem"
}
variable "fingerprint"{
  default = "e6:65:1d:3f:8f:94:XX:8f:a0:6a:9c:9b:45:a1"
}
variable "compartment_ocid" {
  #Compartment-15Nov
  default = "ocid1.compartment.oc1..aaaaaaaXXXXexkqukwwbzx5nuauaa"
}
variable "ssh_public_key" { 
   # cat id_rsa.pub       
   default =  "ssh-rsa AAAAB3NzaC1yc2EAAAAXXXXXuZw== [email protected]" 
}
variable "ssh_private_key" { 
    default = "/Users/madhusudhanrao/tf/keys/myopensslkey.pem"
}

vnic.tf

We will create a VNC with name nov15vnc ,

subnet name as examplesubnet

Network Security Group as TestNetworkSecurityGroup

Instance Name as TestInstance , Oracle Linux 7.5 Image

Instance Shape as VM Standard 2.1

 
// Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

#variable "tenancy_ocid" {}

#variable "user_ocid" {}

#variable "fingerprint" {}

#variable "private_key_path" {}

#variable "compartment_ocid" {}

#variable "region" {}

#variable "ssh_public_key" {}

variable "secondary_vnic_count" {
  default = 1
}

variable "instance_image_ocid" {
  type = map(string)

  default = {
    # See https://docs.us-phoenix-1.oraclecloud.com/images/
    # Oracle-provided image "Oracle-Linux-7.5-2018.10.16-0"
    us-phoenix-1   = "ocid1.image.oc1.phx.aaaaaaaaoqj42sokaoh42l76wsyhn3k2beuntrh5maj3gmgmzeyr55zzrwwa"
    us-ashburn-1   = "ocid1.image.oc1.iad.aaaaaaaageeenzyuxgia726xur4ztaoxbxyjlxogdhreu3ngfj2gji3bayda"
    eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaaitzn6tdyjer7jl34h2ujz74jwy5nkbukbh55ekp6oyzwrtfa4zma"
    uk-london-1    = "ocid1.image.oc1.uk-london-1.aaaaaaaa32voyikkkzfxyo4xbdmadc2dmvorfxxgdhpnk6dw64fa3l4jh7wa"
  }
}

provider "oci" {
  tenancy_ocid     = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  region           = var.region
}

data "oci_identity_availability_domain" "ad" {
  compartment_id = var.tenancy_ocid
  ad_number      = 1
}

resource "oci_core_vcn" "nov15_vcn" {
  cidr_block     = "10.0.0.0/16"
  compartment_id = var.compartment_ocid
  display_name   = "nov15vcn"
  dns_label      = "nov15vcn"
}

resource "oci_core_subnet" "test_subnet" {
  availability_domain = data.oci_identity_availability_domain.ad.name
  cidr_block          = "10.0.1.0/24"
  display_name        = "TestSubnet"
  compartment_id      = var.compartment_ocid
  vcn_id              = oci_core_vcn.nov15_vcn.id
  route_table_id      = oci_core_vcn.nov15_vcn.default_route_table_id
  security_list_ids   = [oci_core_vcn.nov15_vcn.default_security_list_id]
  dhcp_options_id     = oci_core_vcn.nov15_vcn.default_dhcp_options_id
  dns_label           = "examplesubnet"
}

resource "oci_core_network_security_group" "test_network_security_group" {
  #Required
  compartment_id = var.compartment_ocid
  vcn_id         = oci_core_vcn.nov15_vcn.id 
  #Optional
  display_name = "TestNetworkSecurityGroup"
}

resource "oci_core_instance" "test_instance" {
  availability_domain = data.oci_identity_availability_domain.ad.name
  compartment_id      = var.compartment_ocid
  display_name        = "TestInstance"
  shape               = "VM.Standard2.1" 
  source_details {
    source_type = "image"
    source_id   = var.instance_image_ocid[var.region]
  } 
  create_vnic_details {
    subnet_id      = oci_core_subnet.test_subnet.id
    hostname_label = "testinstance"
  } 
  metadata = {
    ssh_authorized_keys = var.ssh_public_key
  } 
  timeouts {
    create = "60m"
  }
}

resource "oci_core_vnic_attachment" "secondary_vnic_attachment" {
  instance_id  = oci_core_instance.test_instance.id
  display_name = "SecondaryVnicAttachment_${count.index}"

  create_vnic_details {
    subnet_id              = oci_core_subnet.test_subnet.id
    display_name           = "SecondaryVnic_${count.index}"
    assign_public_ip       = true
    skip_source_dest_check = true
    nsg_ids                = [oci_core_network_security_group.test_network_security_group.id]
  }

  count = var.secondary_vnic_count
}

data "oci_core_vnic" "secondary_vnic" {
  count = var.secondary_vnic_count
  vnic_id = element(
    oci_core_vnic_attachment.secondary_vnic_attachment.*.vnic_id,
    count.index,
  )
}

output "primary_ip_addresses" {
  value = [
    oci_core_instance.test_instance.public_ip,
    oci_core_instance.test_instance.private_ip,
  ]
}

output "secondary_public_ip_addresses" {
  value = [data.oci_core_vnic.secondary_vnic.*.public_ip_address]
}

output "secondary_private_ip_addresses" {
  value = [data.oci_core_vnic.secondary_vnic.*.private_ip_address]
}


terraform init

- statements ignored -

terraform plan

- statements ignored -

terraform apply

[email protected] mytf-vnc % terraform apply
data.oci_identity_availability_domain.ad: Refreshing state... 
[id=ocid1.availabilitydomain.oc1..aaaaaaaatXXXXXagqrfhcb7mxsfdq]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
 <= read (data resources)

Terraform will perform the following actions:

  # data.oci_core_vnic.secondary_vnic[0] will be read during apply
  # (config refers to values not yet known)
 <= data "oci_core_vnic" "secondary_vnic"  {
      + availability_domain    = (known after apply)
      + compartment_id         = (known after apply)
      + defined_tags           = (known after apply)
      + display_name           = (known after apply)
      + freeform_tags          = (known after apply)
      + hostname_label         = (known after apply)
      + id                     = (known after apply)
      + is_primary             = (known after apply)
      + mac_address            = (known after apply)
      + nsg_ids                = (known after apply)
      + private_ip_address     = (known after apply)
      + public_ip_address      = (known after apply)
      + skip_source_dest_check = (known after apply)
      + state                  = (known after apply)
      + subnet_id              = (known after apply)
      + time_created           = (known after apply)
      + vlan_id                = (known after apply)
      + vnic_id                = (known after apply)
    }

  # oci_core_instance.test_instance will be created
  + resource "oci_core_instance" "test_instance" {
      + availability_domain                 = "mKWN:US-ASHBURN-AD-1"
      + boot_volume_id                      = (known after apply)
      + compartment_id                      = "ocid1.compartment.oc1..aaaaaaaXXXXXbzx5nuauaa"
      + dedicated_vm_host_id                = (known after apply)
      + defined_tags                        = (known after apply)
      + display_name                        = "TestInstance"
      + fault_domain                        = (known after apply)
      + freeform_tags                       = (known after apply)
      + hostname_label                      = (known after apply)
      + id                                  = (known after apply)
      + image                               = (known after apply)
      + ipxe_script                         = (known after apply)
      + is_pv_encryption_in_transit_enabled = (known after apply)
      + launch_mode                         = (known after apply)
      + metadata                            = {
          + "ssh_authorized_keys" = "ssh-rsa AAAAB3NzaC1yXXXXXXX4kmtnCR6TihglaQ8QbXVi5nB5yauZw== [email protected]"
        }
      + private_ip                          = (known after apply)
      + public_ip                           = (known after apply)
      + region                              = (known after apply)
      + shape                               = "VM.Standard2.1"
      + state                               = (known after apply)
      + subnet_id                           = (known after apply)
      + system_tags                         = (known after apply)
      + time_created                        = (known after apply)
      + time_maintenance_reboot_due         = (known after apply)

      + agent_config {
          + is_management_disabled = (known after apply)
          + is_monitoring_disabled = (known after apply)
        }

      + availability_config {
          + recovery_action = (known after apply)
        }

      + create_vnic_details {
          + assign_public_ip       = "true"
          + defined_tags           = (known after apply)
          + display_name           = (known after apply)
          + freeform_tags          = (known after apply)
          + hostname_label         = "testinstance"
          + private_ip             = (known after apply)
          + skip_source_dest_check = (known after apply)
          + subnet_id              = (known after apply)
          + vlan_id                = (known after apply)
        }

      + instance_options {
          + are_legacy_imds_endpoints_disabled = (known after apply)
        }

      + launch_options {
          + boot_volume_type                    = (known after apply)
          + firmware                            = (known after apply)
          + is_consistent_volume_naming_enabled = (known after apply)
          + is_pv_encryption_in_transit_enabled = (known after apply)
          + network_type                        = (known after apply)
          + remote_data_volume_type             = (known after apply)
        }

      + shape_config {
          + gpu_description               = (known after apply)
          + gpus                          = (known after apply)
          + local_disk_description        = (known after apply)
          + local_disks                   = (known after apply)
          + local_disks_total_size_in_gbs = (known after apply)
          + max_vnic_attachments          = (known after apply)
          + memory_in_gbs                 = (known after apply)
          + networking_bandwidth_in_gbps  = (known after apply)
          + ocpus                         = (known after apply)
          + processor_description         = (known after apply)
        }

      + source_details {
          + boot_volume_size_in_gbs = (known after apply)
          + kms_key_id              = (known after apply)
          + source_id               = "ocid1.image.oc1.iad.aaaaaaaageeenzyuxgia726xur4ztaoxbxyjlxogdhreu3ngfj2gji3bayda"
          + source_type             = "image"
        }

      + timeouts {
          + create = "60m"
        }
    }

  # oci_core_network_security_group.test_network_security_group will be created
  + resource "oci_core_network_security_group" "test_network_security_group" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaahb7s4w3XXXXXwwbzx5nuauaa"
      + defined_tags   = (known after apply)
      + display_name   = "TestNetworkSecurityGroup"
      + freeform_tags  = (known after apply)
      + id             = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # oci_core_subnet.test_subnet will be created
  + resource "oci_core_subnet" "test_subnet" {
      + availability_domain        = "mKWN:US-ASHBURN-AD-1"
      + cidr_block                 = "10.0.1.0/24"
      + compartment_id             = "ocid1.compartment.oc1..aaaaaaaahb7XXXXXXzx5nuauaa"
      + defined_tags               = (known after apply)
      + dhcp_options_id            = (known after apply)
      + display_name               = "TestSubnet"
      + dns_label                  = "examplesubnet"
      + 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_vcn.nov15_vcn will be created
  + resource "oci_core_vcn" "nov15_vcn" {
      + cidr_block               = "10.0.0.0/16"
      + cidr_blocks              = (known after apply)
      + compartment_id           = "ocid1.compartment.oc1..aaaaaaaaXXXXXXwbzx5nuauaa"
      + 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             = "nov15vcn"
      + dns_label                = "nov15vcn"
      + freeform_tags            = (known after apply)
      + 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)
    }

  # oci_core_vnic_attachment.secondary_vnic_attachment[0] will be created
  + resource "oci_core_vnic_attachment" "secondary_vnic_attachment" {
      + availability_domain = (known after apply)
      + compartment_id      = (known after apply)
      + display_name        = "SecondaryVnicAttachment_0"
      + id                  = (known after apply)
      + instance_id         = (known after apply)
      + nic_index           = (known after apply)
      + state               = (known after apply)
      + subnet_id           = (known after apply)
      + time_created        = (known after apply)
      + vlan_id             = (known after apply)
      + vlan_tag            = (known after apply)
      + vnic_id             = (known after apply)

      + create_vnic_details {
          + assign_public_ip       = "true"
          + defined_tags           = (known after apply)
          + display_name           = "SecondaryVnic_0"
          + freeform_tags          = (known after apply)
          + hostname_label         = (known after apply)
          + nsg_ids                = (known after apply)
          + private_ip             = (known after apply)
          + skip_source_dest_check = true
          + subnet_id              = (known after apply)
          + vlan_id                = (known after apply)
        }
    }

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

Changes to Outputs:
  ~ primary_ip_addresses           = [
      - "132.145.174.152",
      - "10.0.1.2",
      + (known after apply),
      + (known after apply),
    ]
  ~ secondary_private_ip_addresses = [
      - [
          - "10.0.1.3",
        ],
      + [
          + (known after apply),
        ],
    ]
  ~ secondary_public_ip_addresses  = [
      - [
          - "150.136.240.70",
        ],
      + [
          + (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

oci_core_vcn.nov15_vcn: Creating...
oci_core_vcn.nov15_vcn: Creation complete after 4s [id=ocid1.vcn.oc1.iad.amaaaaaafvl7zXXXXXXivjpoowq]
oci_core_network_security_group.test_network_security_group: Creating...
oci_core_subnet.test_subnet: Creating...
oci_core_network_security_group.test_network_security_group: Creation complete after 1s [id=ocid1.networksecuritygroup.oc1.iad.aaaaaaaa3zt3XXXXjlmacxzgysbiba]
oci_core_subnet.test_subnet: Creation complete after 3s [id=ocid1.subnet.oc1.iad.aaaaaaaa7ijtavaayvlmbpXXXXXqozjoeu3yqxn237q]
oci_core_instance.test_instance: Creating...
oci_core_instance.test_instance: Still creating... [10s elapsed]
oci_core_instance.test_instance: Still creating... [20s elapsed]
oci_core_instance.test_instance: Still creating... [30s elapsed]
oci_core_instance.test_instance: Still creating... [40s elapsed]
oci_core_instance.test_instance: Still creating... [50s elapsed]
oci_core_instance.test_instance: Still creating... [1m0s elapsed]
oci_core_instance.test_instance: Creation complete after 1m10s [id=ocid1.instance.oc1.iad.anuwcljtfvl7zmicXXXXXhyafwoemu5a]
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Creating...
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Creation complete after 10s [id=ocid1.vnicattachment.oc1.iad.anuwcljtfvl7XXXXXXlis25353cq]
data.oci_core_vnic.secondary_vnic[0]: Reading...
data.oci_core_vnic.secondary_vnic[0]: Read complete after 0s [id=ocid1.vnic.oc1.iad.abuwcljtqqcoq3XXXX7krfmu3rrgpq]

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

Outputs:

primary_ip_addresses = [
  "129.X.Y.185",
  "10.0.1.2",
]
secondary_private_ip_addresses = [
  [
    "10.0.1.3",
  ],
]
secondary_public_ip_addresses = [
  [
    "193.A.B.253",
  ],
]
[email protected] mytf-vnc % 

Reality Check

login to cloud console https://console.us-ashburn-1.oraclecloud.com/ and you should be able to see your newly created Ubuntu Instance and Newly created Network

VNC

DHCP Options

Security Group

CIDR Blocks

Security List > Egress Rule

Security List > Ingress Rule

Security List  

Subnet

Cleanup what was created .

[email protected] mytf-vnc % terraform destroy
data.oci_identity_availability_domain.ad: Refreshing state... [id=ocid1.availabilitydomain.oc1..aaaaaaaatrwxaogrXXXXbnomiagqrfhcb7mxsfdq]
oci_core_vcn.nov15_vcn: Refreshing state... [id=ocid1.vcn.oc1.iad.amaaaaaafvl7zmialzxrjgslsfcj5hjpjjl4XXXivjpoowq]
oci_core_network_security_group.test_network_security_group: Refreshing state... [id=ocid1.networksecuritygroup.oc1.iad.aaaaaaaa3XXXX3jlmacxzgysbiba]
oci_core_subnet.test_subnet: Refreshing state... [id=ocid1.subnet.oc1.iad.aaaaaaaa7ijtavaayvXXXXqxn237q]
oci_core_instance.test_instance: Refreshing state... [id=ocid1.instance.oc1.iad.anuwcljtfvl7zmicpgiw5ot4c3ja5XXXXuyhyafwoemu5a]
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Refreshing state... [id=ocid1.vnicattachment.oc1.iad.anXXXwb27u5dz5rtlis25353cq]
data.oci_core_vnic.secondary_vnic[0]: Refreshing state... [id=ocid1.vnic.oc1.iad.abuwcljtqqcoq3ghscnwjgby3awqyylXXXrgpq]

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

Terraform will perform the following actions:

  # oci_core_instance.test_instance will be destroyed
  - resource "oci_core_instance" "test_instance" {
      - availability_domain = "mKWN:US-ASHBURN-AD-1" -> null
      - boot_volume_id      = "ocid1.bootvolume.oc1.iad.abuwcljtn3giiqvymXXXXXjs4fvomxce4sq" -> null
      - compartment_id      = "ocid1.compartment.oc1..aaaaaaaahb7s4w3lXXXXkwwbzx5nuauaa" -> null
      - defined_tags        = {
          - "Oracle-Tags.CreatedBy" = "[email protected]"
          - "Oracle-Tags.CreatedOn" = "2020-11-15T11:37:41.892Z"
        } -> null
      - display_name        = "TestInstance" -> null
      - extended_metadata   = {} -> null
      - fault_domain        = "FAULT-DOMAIN-2" -> null
      - freeform_tags       = {} -> null
      - hostname_label      = "testinstance" -> null
      - id                  = "ocid1.instance.oc1.iad.anuwcljtfvl7zmiXXXXhyafwoemu5a" -> null
      - image               = "ocid1.image.oc1.iad.aaaaaaaageXXXXgji3bayda" -> null
      - launch_mode         = "NATIVE" -> null
      - metadata            = {
          - "ssh_authorized_keys" = "ssh-rsa AAAAB3NzaC1yXXXX== [email protected]"
        } -> null
      - private_ip          = "10.0.1.2" -> null
      - public_ip           = "129.213.118.185" -> null
      - region              = "iad" -> null
      - shape               = "VM.Standard2.1" -> null
      - state               = "RUNNING" -> null
      - subnet_id           = "ocid1.subnet.oc1.iad.aaaaaaaa7ijtaXXXXyqxn237q" -> null
      - system_tags         = {} -> null
      - time_created        = "2020-11-15 11:37:42.893 +0000 UTC" -> null

      - agent_config {
          - is_management_disabled = false -> null
          - is_monitoring_disabled = false -> null
        }

      - availability_config {
          - recovery_action = "RESTORE_INSTANCE" -> null
        }

      - create_vnic_details {
          - assign_public_ip       = "true" -> null
          - defined_tags           = {
              - "Oracle-Tags.CreatedBy" = "[email protected]"
              - "Oracle-Tags.CreatedOn" = "2020-11-15T11:37:42.173Z"
            } -> null
          - display_name           = "TestInstance" -> null
          - freeform_tags          = {} -> null
          - hostname_label         = "testinstance" -> null
          - nsg_ids                = [] -> null
          - private_ip             = "10.0.1.2" -> null
          - skip_source_dest_check = false -> null
          - subnet_id              = "ocid1.subnet.oc1.iad.aaaaaaaa7ijXXXXjoeu3yqxn237q" -> null
        }

      - instance_options {
          - are_legacy_imds_endpoints_disabled = false -> null
        }

      - launch_options {
          - boot_volume_type                    = "PARAVIRTUALIZED" -> null
          - firmware                            = "UEFI_64" -> null
          - is_consistent_volume_naming_enabled = false -> null
          - is_pv_encryption_in_transit_enabled = false -> null
          - network_type                        = "VFIO" -> null
          - remote_data_volume_type             = "PARAVIRTUALIZED" -> null
        }

      - shape_config {
          - gpus                          = 0 -> null
          - local_disks                   = 0 -> null
          - local_disks_total_size_in_gbs = 0 -> null
          - max_vnic_attachments          = 2 -> null
          - memory_in_gbs                 = 15 -> null
          - networking_bandwidth_in_gbps  = 1 -> null
          - ocpus                         = 1 -> null
          - processor_description         = "2.0 GHz Intel® Xeon® Platinum 8167M (Skylake)" -> null
        }

      - source_details {
          - boot_volume_size_in_gbs = "47" -> null
          - source_id               = "ocid1.image.oc1.iad.aaaaaaaageeenzyuXXXXgji3bayda" -> null
          - source_type             = "image" -> null
        }

      - timeouts {
          - create = "60m" -> null
        }
    }

  # oci_core_network_security_group.test_network_security_group will be destroyed
  - resource "oci_core_network_security_group" "test_network_security_group" {
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaahb7s4w3laXXXXaexkqukwwbzx5nuauaa" -> null
      - defined_tags   = {
          - "Oracle-Tags.CreatedBy" = "[email protected]"
          - "Oracle-Tags.CreatedOn" = "2020-11-15T11:37:38.158Z"
        } -> null
      - display_name   = "TestNetworkSecurityGroup" -> null
      - freeform_tags  = {} -> null
      - id             = "ocid1.networksecuritygroup.oc1.iad.aaaaaaaa3zt3hXXXXlmacxzgysbiba" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2020-11-15 11:37:38.188 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.iad.amaaaaaafvl7zmialzxrjgslsfcj5hjpjjl4qczvuunl6b64d73eivjpoowq" -> null
    }

  # oci_core_subnet.test_subnet will be destroyed
  - resource "oci_core_subnet" "test_subnet" {
      - availability_domain        = "mKWN:US-ASHBURN-AD-1" -> null
      - cidr_block                 = "10.0.1.0/24" -> null
      - compartment_id             = "ocid1.compartment.oc1..aaaaaaaahb7s4XXXXqukwwbzx5nuauaa" -> null
      - defined_tags               = {
          - "Oracle-Tags.CreatedBy" = "[email protected]"
          - "Oracle-Tags.CreatedOn" = "2020-11-15T11:37:38.795Z"
        } -> null
      - dhcp_options_id            = "ocid1.dhcpoptions.oc1.iad.aaaaaaaadxzbXXXXqgjhwnyfgkyq" -> null
      - display_name               = "TestSubnet" -> null
      - dns_label                  = "examplesubnet" -> null
      - freeform_tags              = {} -> null
      - id                         = "ocid1.subnet.oc1.iad.aaaaaaaa7ijtavaayvlmbpyhkXXXXzjoeu3yqxn237q" -> null
      - prohibit_public_ip_on_vnic = false -> null
      - route_table_id             = "ocid1.routetable.oc1.iad.aaaaaaaa4cq53XXXXtehcfglxa4ytqa" -> null
      - security_list_ids          = [
          - "ocid1.securitylist.oc1.iad.aaaaaaaapliq23f77hieipzzg7whsux7mrm7z3q3bvvdf35gjkh4vf4wccwa",
        ] -> null
      - state                      = "AVAILABLE" -> null
      - subnet_domain_name         = "examplesubnet.nov15vcn.oraclevcn.com" -> null
      - time_created               = "2020-11-15 11:37:38.895 +0000 UTC" -> null
      - vcn_id                     = "ocid1.vcn.oc1.iad.amaaaaaafvl7zmialXXXX73eivjpoowq" -> null
      - virtual_router_ip          = "10.0.1.1" -> null
      - virtual_router_mac         = "00:00:17:C6:A1:36" -> null
    }

  # oci_core_vcn.nov15_vcn will be destroyed
  - resource "oci_core_vcn" "nov15_vcn" {
      - cidr_block               = "10.0.0.0/16" -> null
      - cidr_blocks              = [
          - "10.0.0.0/16",
        ] -> null
      - compartment_id           = "ocid1.compartment.oc1..aaaaaaaahb7s4XXXjaexkqukwwbzx5nuauaa" -> null
      - default_dhcp_options_id  = "ocid1.dhcpoptions.oc1.iad.aaaaaaaaXXXXqgjhwnyfgkyq" -> null
      - default_route_table_id   = "ocid1.routetable.oc1.iad.aaaaaaaaXXXXhcfglxa4ytqa" -> null
      - default_security_list_id = "ocid1.securitylist.oc1.iad.aaaaaaaaXXXXkh4vf4wccwa" -> null
      - defined_tags             = {
          - "Oracle-Tags.CreatedBy" = "[email protected]"
          - "Oracle-Tags.CreatedOn" = "2020-11-15T11:37:37.046Z"
        } -> null
      - display_name             = "nov15vcn" -> null
      - dns_label                = "nov15vcn" -> null
      - freeform_tags            = {} -> null
      - id                       = "ocid1.vcn.oc1.iad.amaaaaaafvl7zmialzxrjgXXXX3eivjpoowq" -> null
      - state                    = "AVAILABLE" -> null
      - time_created             = "2020-11-15 11:37:37.049 +0000 UTC" -> null
      - vcn_domain_name          = "nov15vcn.oraclevcn.com" -> null
    }

  # oci_core_vnic_attachment.secondary_vnic_attachment[0] will be destroyed
  - resource "oci_core_vnic_attachment" "secondary_vnic_attachment" {
      - availability_domain = "mKWN:US-ASHBURN-AD-1" -> null
      - compartment_id      = "ocid1.compartment.oc1..aaaaaaaahb7s4w3larbXXXXbzx5nuauaa" -> null
      - display_name        = "SecondaryVnicAttachment_0" -> null
      - id                  = "ocid1.vnicattachment.oc1.iad.anuwcljtfvl7zmicslgpXXXz5rtlis25353cq" -> null
      - instance_id         = "ocid1.instance.oc1.iad.anuwcljtfvl7zmiXXXhyafwoemu5a" -> null
      - nic_index           = 0 -> null
      - state               = "ATTACHED" -> null
      - subnet_id           = "ocid1.subnet.oc1.iad.aaaaaaaa7ijtaXXXXqozjoeu3yqxn237q" -> null
      - time_created        = "2020-11-15 11:38:52.215 +0000 UTC" -> null
      - vlan_tag            = 203 -> null
      - vnic_id             = "ocid1.vnic.oc1.iad.abuwcljtqqcoXXXXn7krfmu3rrgpq" -> null

      - create_vnic_details {
          - assign_public_ip       = "true" -> null
          - defined_tags           = {
              - "Oracle-Tags.CreatedBy" = "[email protected]"
              - "Oracle-Tags.CreatedOn" = "2020-11-15T11:38:51.775Z"
            } -> null
          - display_name           = "SecondaryVnic_0" -> null
          - freeform_tags          = {} -> null
          - nsg_ids                = [
              - "ocid1.networksecuritygroup.oc1.iad.aaaaaaaa3zt3hxXXXXacxzgysbiba",
            ] -> null
          - private_ip             = "10.0.1.3" -> null
          - skip_source_dest_check = true -> null
          - subnet_id              = "ocid1.subnet.oc1.iad.aaaaaaaa7iXXXXoeu3yqxn237q" -> null
        }
    }

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

Changes to Outputs:
  - primary_ip_addresses           = [
      - "129.213.118.185",
      - "10.0.1.2",
    ] -> null
  - secondary_private_ip_addresses = [
      - [
          - "10.0.1.3",
        ],
    ] -> null
  - secondary_public_ip_addresses  = [
      - [
          - "193.122.151.253",
        ],
    ] -> null

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

oci_core_vnic_attachment.secondary_vnic_attachment[0]: Destroying... [id=ocid1.vnicattachment.oc1.iad.anuwcljtfvl7zmicslgpoamlzq6kyaa5n44gkxcwb27u5dz5rtlis25353cq]
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Still destroying... [id=ocid1.vnicattachment.oc1.iad.anuwcljtfv...XXXX, 10s elapsed]
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Still destroying... [id=ocid1.vnicattachment.oc1.iad.anuwcljtfv...XXXX, 20s elapsed]
oci_core_vnic_attachment.secondary_vnic_attachment[0]: Destruction complete after 28s
oci_core_network_security_group.test_network_security_group: Destroying... [id=ocid1.networksecuritygroup.oc1.iad.aaaaaaaa3ztXXXacxzgysbiba]
oci_core_instance.test_instance: Destroying... [id=ocid1.instance.oc1.iad.anuwcljtfvl7zmicpgiw5ot4c3ja5ms24mf2yg4ewgnhfuiuyhyafwoemu5a]
oci_core_network_security_group.test_network_security_group: Destruction complete after 2s
oci_core_instance.test_instance: Still destroying... [id=ocid1.instance.oc1.iad.anuwcljtfvl7zmic...XXXX, 10s elapsed]
 oci_core_instance.test_instance: Still destroying... [id=ocid1.instance.oc1.iad.anuwcljtfvl7zmic...XXX, 2m20s elapsed]
oci_core_instance.test_instance: Destruction complete after 2m21s
oci_core_subnet.test_subnet: Destroying... [id=ocid1.subnet.oc1.iad.aaaaaaaa7XXX7lg2s66sqozjoeu3yqxn237q]
oci_core_subnet.test_subnet: Destruction complete after 1s
oci_core_vcn.nov15_vcn: Destroying... [id=ocid1.vcn.oc1.iad.amaaaaaafvlXXXXivjpoowq]
oci_core_vcn.nov15_vcn: Destruction complete after 1s

Destroy complete! Resources: 5 destroyed.

Possible Errors

Error: Service error:InvalidParameter. DNS Label nov15_vcn does not follow Oracle requirements. 
http status code: 400. Opc request id: 34453e11d70XXXE65709A2BD9898CCDF0A

  on vnic.tf line 48, in resource "oci_core_vcn" "nov15_vcn":
  48: resource "oci_core_vcn" "nov15_vcn" {

Solution : remove _ , that is rename nov15_vnc to just nov15vnc