2
1

TerraformでOCIのVCNを作成する

Posted at

はじめに

前回に続いて、OCIのマニュアルを参考にTerraformでVCNを作成します。

Terraformの設定ファイル作成

認証

前回作成したprovider.tfをそのまま利用します。

provider.tf
provider "oci" {
  tenancy_ocid = "<tenancy-ocid>"
  user_ocid = "<user-ocid>" 
  private_key_path = "<rsa-private-key-path>"
  fingerprint = "<fingerprint>"
  region = "<region-identifier>"
}

terraform {
  required_providers {
    oci = {
      source  = "oracle/oci"
    }
  }
}

データソース

TerraformレジストリBrowse Modulesをクリックし、Providerの中からOracleをチェックします。
Modulesの中からoracle-terraform-modules/vcnをクリックします。

スクリーンショット 2023-11-02 12.54.49.png

Provision Instructionsのコードをコピーして、vcn-module.tfファイルを作成します。

vcn-module.tf
module "vcn" {
  source  = "oracle-terraform-modules/vcn/oci"
  version = "3.5.5"
  # insert the 1 required variable here
}

必須項目が一つあるので、Inputsをクリックして確認します。

スクリーンショット 2023-11-02 13.05.25.png

全部で22項目ありますが、必須はcompartment_idの一つです。
Optional Inputsを指定しない場合、デフォルト値が設定されます。

今回はcompartment_idの他にOptionalを5つ設定しました。

vcn-module.tf
module "vcn" {
  source  = "oracle-terraform-modules/vcn/oci"
  version = "3.5.5"
  # insert the 1 required variable here

  compartment_id = "<compartment-ocid>"

  # Optional Inputs
  create_internet_gateway = "true"
  create_nat_gateway = "true"
  create_service_gateway = "true"
  region = "<region-identifier>"
  vcn_name = "tf-vcn"
}

出力

oracle-terraform-modules/vcn出力をクリックして、Outputで使用できる属性を確認します。

スクリーンショット 2023-11-02 13.32.21.png

今回はマニュアルの通りですが、以下のファイルを作成しました。

outputs.tf
output "vcn_id" {
  description = "OCID of the VCN that is created"
  value = module.vcn.vcn_id
}
output "id-for-route-table-that-includes-the-internet-gateway" {
  description = "OCID of the internet-route table. This route table has an internet gateway to be used for public subnets"
  value = module.vcn.ig_route_id
}
output "nat-gateway-id" {
  description = "OCID for NAT gateway"
  value = module.vcn.nat_gateway_id
}
output "id-for-for-route-table-that-includes-the-nat-gateway" {
  description = "OCID of the nat-route table - This route table has a nat gateway to be used for private subnets. This route table also has a service gateway."
  value = module.vcn.nat_route_id
}
項目 説明
output 出力結果とともに表示されるラベルを設定
description コードブロックの説明(オプション)
value module.<vcn-module.tfで指定したモジュール名>.<属性名>

設定ファイルとして、以下の3つを作成しました。

$ ls -l tf-vcn/
total 36
-rw-rw-r--. 1 opc opc   683 Nov  2 04:45 outputs.tf
-rw-rw-r--. 1 opc opc   445 Nov  1 23:43 provider.tf
-rw-rw-r--. 1 opc opc   396 Nov  2 04:13 vcn-module.tf

Terraformの実行

init

$ terraform init

Initializing the backend...
Initializing modules...
Downloading registry.terraform.io/oracle-terraform-modules/vcn/oci 3.5.5 for vcn...
- vcn in .terraform/modules/vcn
- vcn.subnet in .terraform/modules/vcn/modules/subnet

Initializing provider plugins...
- Finding oracle/oci versions matching ">= 4.67.3"...
- Installing oracle/oci v5.19.0...
- Installed oracle/oci v5.19.0 (signed by a HashiCorp partner, key ID 1533A49284137CEB)

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

plan

$ terraform plan
module.vcn.data.oci_core_services.all_oci_services[0]: Reading...
module.vcn.data.oci_core_services.all_oci_services[0]: Read complete after 0s [id=CoreServicesDataSource-0]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.vcn.oci_core_default_security_list.lockdown[0] will be created
  + resource "oci_core_default_security_list" "lockdown" {
      + compartment_id             = (known after apply)
      + defined_tags               = (known after apply)
      + display_name               = (known after apply)
      + freeform_tags              = (known after apply)
      + id                         = (known after apply)
      + manage_default_resource_id = (known after apply)
      + state                      = (known after apply)
      + time_created               = (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..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "internet-gateway"
      + enabled        = true
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)
    }

  # module.vcn.oci_core_nat_gateway.nat_gateway[0] will be created
  + resource "oci_core_nat_gateway" "nat_gateway" {
      + block_traffic  = (known after apply)
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "nat-gateway"
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + id             = (known after apply)
      + nat_ip         = (known after apply)
      + public_ip_id   = (known after apply)
      + route_table_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..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "internet-route"
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + 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       = "Terraformed - Auto-generated at Internet Gateway creation: Internet Gateway as default gateway"
          + destination       = "0.0.0.0/0"
          + destination_type  = (known after apply)
          + network_entity_id = (known after apply)
          + route_type        = (known after apply)
        }
    }

  # module.vcn.oci_core_route_table.nat[0] will be created
  + resource "oci_core_route_table" "nat" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "nat-route"
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + 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       = "Terraformed - Auto-generated at NAT Gateway creation: NAT Gateway as default gateway"
          + destination       = "0.0.0.0/0"
          + destination_type  = "CIDR_BLOCK"
          + network_entity_id = (known after apply)
          + route_type        = (known after apply)
        }
      + route_rules {
          + cidr_block        = (known after apply)
          + description       = "Terraformed - Auto-generated at Service Gateway creation: All Services in region to Service Gateway"
          + destination       = "all-syd-services-in-oracle-services-network"
          + destination_type  = "SERVICE_CIDR_BLOCK"
          + network_entity_id = (known after apply)
          + route_type        = (known after apply)
        }
    }

  # module.vcn.oci_core_route_table.service_gw[0] will be created
  + resource "oci_core_route_table" "service_gw" {
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "service-gw-route"
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + 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       = "Terraformed - Auto-generated at Service Gateway creation: All Services in region to Service Gateway"
          + destination       = "all-syd-services-in-oracle-services-network"
          + destination_type  = "SERVICE_CIDR_BLOCK"
          + network_entity_id = (known after apply)
          + route_type        = (known after apply)
        }
    }

  # module.vcn.oci_core_service_gateway.service_gateway[0] will be created
  + resource "oci_core_service_gateway" "service_gateway" {
      + block_traffic  = (known after apply)
      + compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + defined_tags   = (known after apply)
      + display_name   = "service-gateway"
      + freeform_tags  = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + state          = (known after apply)
      + time_created   = (known after apply)
      + vcn_id         = (known after apply)

      + services {
          + service_id   = "ocid1.service.oc1.ap-sydney-1.aaaaaaaaar6xfo4rtfjgv2mmjvo7u77zyr4uyqkc764f2t2jxwwayrjhsjyq"
          + service_name = (known after apply)
        }
    }

  # module.vcn.oci_core_vcn.vcn will be created
  + resource "oci_core_vcn" "vcn" {
      + byoipv6cidr_blocks               = (known after apply)
      + cidr_block                       = (known after apply)
      + cidr_blocks                      = [
          + "10.0.0.0/16",
        ]
      + compartment_id                   = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a"
      + 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                     = "tf-vcn"
      + dns_label                        = "vcnmodule"
      + freeform_tags                    = {
          + "module"      = "oracle-terraform-modules/vcn/oci"
          + "terraformed" = "Please do not edit manually"
        }
      + id                               = (known after apply)
      + ipv6cidr_blocks                  = (known after apply)
      + ipv6private_cidr_blocks          = (known after apply)
      + is_ipv6enabled                   = false
      + is_oracle_gua_allocation_enabled = (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:
  + id-for-for-route-table-that-includes-the-nat-gateway  = (known after apply)
  + id-for-route-table-that-includes-the-internet-gateway = (known after apply)
  + nat-gateway-id                                        = (known after apply)
  + vcn_id                                                = (known after apply)

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

以下のように8つのリソースが作成されることが表示されます。
Plan: 8 to add, 0 to change, 0 to destroy.

apply

$ terraform apply
module.vcn.data.oci_core_services.all_oci_services[0]: Reading...
module.vcn.data.oci_core_services.all_oci_services[0]: Read complete after 0s [id=CoreServicesDataSource-0]

・・・省略

  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.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq]
module.vcn.oci_core_nat_gateway.nat_gateway[0]: Creating...
module.vcn.oci_core_default_security_list.lockdown[0]: Creating...
module.vcn.oci_core_service_gateway.service_gateway[0]: Creating...
module.vcn.oci_core_internet_gateway.ig[0]: Creating...
module.vcn.oci_core_default_security_list.lockdown[0]: Creation complete after 0s [id=ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq]
module.vcn.oci_core_internet_gateway.ig[0]: Creation complete after 0s [id=ocid1.internetgateway.oc1.ap-sydney-1.aaaaaaaaaj2chi3wsveij5mtotea3okp2z5y2ftagcaja6w6w56uzu5dpaba]
module.vcn.oci_core_route_table.ig[0]: Creating...
module.vcn.oci_core_service_gateway.service_gateway[0]: Creation complete after 0s [id=ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq]
module.vcn.oci_core_route_table.service_gw[0]: Creating...
module.vcn.oci_core_route_table.ig[0]: Creation complete after 1s [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a]
module.vcn.oci_core_route_table.service_gw[0]: Creation complete after 1s [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaafgedj7y5bimpsr72v3fvmeqcr5sigodg2oy4v3wlhhdc2xrn5rxq]
module.vcn.oci_core_nat_gateway.nat_gateway[0]: Creation complete after 2s [id=ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq]
module.vcn.oci_core_route_table.nat[0]: Creating...
module.vcn.oci_core_route_table.nat[0]: Creation complete after 0s [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq]

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

Outputs:

id-for-for-route-table-that-includes-the-nat-gateway = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq"
id-for-route-table-that-includes-the-internet-gateway = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a"
nat-gateway-id = "ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq"
vcn_id = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq"

OCIのコンソールでも作成されたことを確認します。

スクリーンショット 2023-11-02 13.52.43.png

destroy

$ terraform destroy
module.vcn.data.oci_core_services.all_oci_services[0]: Reading...
module.vcn.oci_core_vcn.vcn: Refreshing state... [id=ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq]
module.vcn.data.oci_core_services.all_oci_services[0]: Read complete after 0s [id=CoreServicesDataSource-0]
module.vcn.oci_core_internet_gateway.ig[0]: Refreshing state... [id=ocid1.internetgateway.oc1.ap-sydney-1.aaaaaaaaaj2chi3wsveij5mtotea3okp2z5y2ftagcaja6w6w56uzu5dpaba]
module.vcn.oci_core_default_security_list.lockdown[0]: Refreshing state... [id=ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq]
module.vcn.oci_core_nat_gateway.nat_gateway[0]: Refreshing state... [id=ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq]
module.vcn.oci_core_service_gateway.service_gateway[0]: Refreshing state... [id=ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq]
module.vcn.oci_core_route_table.ig[0]: Refreshing state... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a]
module.vcn.oci_core_route_table.service_gw[0]: Refreshing state... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaafgedj7y5bimpsr72v3fvmeqcr5sigodg2oy4v3wlhhdc2xrn5rxq]
module.vcn.oci_core_route_table.nat[0]: Refreshing state... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # module.vcn.oci_core_default_security_list.lockdown[0] will be destroyed
  - resource "oci_core_default_security_list" "lockdown" {
      - compartment_id             = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags               = {} -> null
      - display_name               = "Default Security List for tf-vcn" -> null
      - freeform_tags              = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id                         = "ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq" -> null
      - manage_default_resource_id = "ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq" -> null
      - state                      = "AVAILABLE" -> null
      - time_created               = "2023-11-02 04:48:53.411 +0000 UTC" -> null
    }

  # module.vcn.oci_core_internet_gateway.ig[0] will be destroyed
  - resource "oci_core_internet_gateway" "ig" {
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "internet-gateway" -> null
      - enabled        = true -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.internetgateway.oc1.ap-sydney-1.aaaaaaaaaj2chi3wsveij5mtotea3okp2z5y2ftagcaja6w6w56uzu5dpaba" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:53.886 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null
    }

  # module.vcn.oci_core_nat_gateway.nat_gateway[0] will be destroyed
  - resource "oci_core_nat_gateway" "nat_gateway" {
      - block_traffic  = false -> null
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "nat-gateway" -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq" -> null
      - nat_ip         = "192.9.169.223" -> null
      - public_ip_id   = "ocid1.publicip.oc1.ap-sydney-1.aaaaaaaatq4s5k2mkxiiwd5dbmz2b3tjixkilrp6uuabdigy3rcsksp76iuq" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:54.688 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null
    }

  # module.vcn.oci_core_route_table.ig[0] will be destroyed
  - resource "oci_core_route_table" "ig" {
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "internet-route" -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:54.295 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null

      - route_rules {
          - description       = "Terraformed - Auto-generated at Internet Gateway creation: Internet Gateway as default gateway" -> null
          - destination       = "0.0.0.0/0" -> null
          - destination_type  = "CIDR_BLOCK" -> null
          - network_entity_id = "ocid1.internetgateway.oc1.ap-sydney-1.aaaaaaaaaj2chi3wsveij5mtotea3okp2z5y2ftagcaja6w6w56uzu5dpaba" -> null
        }
    }

  # module.vcn.oci_core_route_table.nat[0] will be destroyed
  - resource "oci_core_route_table" "nat" {
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "nat-route" -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:55.695 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null

      - route_rules {
          - description       = "Terraformed - Auto-generated at NAT Gateway creation: NAT Gateway as default gateway" -> null
          - destination       = "0.0.0.0/0" -> null
          - destination_type  = "CIDR_BLOCK" -> null
          - network_entity_id = "ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq" -> null
        }
      - route_rules {
          - description       = "Terraformed - Auto-generated at Service Gateway creation: All Services in region to Service Gateway" -> null
          - destination       = "all-syd-services-in-oracle-services-network" -> null
          - destination_type  = "SERVICE_CIDR_BLOCK" -> null
          - network_entity_id = "ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq" -> null
        }
    }

  # module.vcn.oci_core_route_table.service_gw[0] will be destroyed
  - resource "oci_core_route_table" "service_gw" {
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "service-gw-route" -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaafgedj7y5bimpsr72v3fvmeqcr5sigodg2oy4v3wlhhdc2xrn5rxq" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:54.605 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null

      - route_rules {
          - description       = "Terraformed - Auto-generated at Service Gateway creation: All Services in region to Service Gateway" -> null
          - destination       = "all-syd-services-in-oracle-services-network" -> null
          - destination_type  = "SERVICE_CIDR_BLOCK" -> null
          - network_entity_id = "ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq" -> null
        }
    }

  # module.vcn.oci_core_service_gateway.service_gateway[0] will be destroyed
  - resource "oci_core_service_gateway" "service_gateway" {
      - block_traffic  = false -> null
      - compartment_id = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - defined_tags   = {} -> null
      - display_name   = "service-gateway" -> null
      - freeform_tags  = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id             = "ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq" -> null
      - state          = "AVAILABLE" -> null
      - time_created   = "2023-11-02 04:48:54.207 +0000 UTC" -> null
      - vcn_id         = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null

      - services {
          - service_id   = "ocid1.service.oc1.ap-sydney-1.aaaaaaaaar6xfo4rtfjgv2mmjvo7u77zyr4uyqkc764f2t2jxwwayrjhsjyq" -> null
          - service_name = "All SYD Services In Oracle Services Network" -> null
        }
    }

  # module.vcn.oci_core_vcn.vcn will be destroyed
  - resource "oci_core_vcn" "vcn" {
      - byoipv6cidr_blocks       = [] -> null
      - cidr_block               = "10.0.0.0/16" -> null
      - cidr_blocks              = [
          - "10.0.0.0/16",
        ] -> null
      - compartment_id           = "ocid1.compartment.oc1..aaaaaaaamyemvazvbgl42f5pi7gzlpgq5tcmxlipjm2uitoihfschylliy5a" -> null
      - default_dhcp_options_id  = "ocid1.dhcpoptions.oc1.ap-sydney-1.aaaaaaaa4i6ywheqswdfkrywbpfxkjegj2werbwrlzqbaoiflultcgw3ei2q" -> null
      - default_route_table_id   = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaa754k24pavx7xoev4jw5xgqkkqcijg6rcx5my7fvvyh7rfkthzdhq" -> null
      - default_security_list_id = "ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq" -> null
      - defined_tags             = {} -> null
      - display_name             = "tf-vcn" -> null
      - dns_label                = "vcnmodule" -> null
      - freeform_tags            = {
          - "module"      = "oracle-terraform-modules/vcn/oci"
          - "terraformed" = "Please do not edit manually"
        } -> null
      - id                       = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> null
      - ipv6cidr_blocks          = [] -> null
      - ipv6private_cidr_blocks  = [] -> null
      - is_ipv6enabled           = false -> null
      - state                    = "AVAILABLE" -> null
      - time_created             = "2023-11-02 04:48:53.411 +0000 UTC" -> null
      - vcn_domain_name          = "vcnmodule.oraclevcn.com" -> null
    }

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

Changes to Outputs:
  - id-for-for-route-table-that-includes-the-nat-gateway  = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq" -> null
  - id-for-route-table-that-includes-the-internet-gateway = "ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a" -> null
  - nat-gateway-id                                        = "ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq" -> null
  - vcn_id                                                = "ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq" -> 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

module.vcn.oci_core_default_security_list.lockdown[0]: Destroying... [id=ocid1.securitylist.oc1.ap-sydney-1.aaaaaaaartfegwvjgunoyog3nnrzibrn7yhtlsb5pbvufwv7g73tmj7ahdeq]
module.vcn.oci_core_route_table.service_gw[0]: Destroying... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaafgedj7y5bimpsr72v3fvmeqcr5sigodg2oy4v3wlhhdc2xrn5rxq]
module.vcn.oci_core_route_table.ig[0]: Destroying... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaajajvq5h5ccgk2jzpfysr2pkxxfdlmttet53awvplxv5hiyns2t6a]
module.vcn.oci_core_route_table.nat[0]: Destroying... [id=ocid1.routetable.oc1.ap-sydney-1.aaaaaaaasn7xtu4k6ohuiysnlksircrvyfz3d55g7yxuy6bj4e4bhbrw3raq]
module.vcn.oci_core_default_security_list.lockdown[0]: Destruction complete after 0s
module.vcn.oci_core_route_table.service_gw[0]: Destruction complete after 0s
module.vcn.oci_core_route_table.nat[0]: Destruction complete after 0s
module.vcn.oci_core_service_gateway.service_gateway[0]: Destroying... [id=ocid1.servicegateway.oc1.ap-sydney-1.aaaaaaaaozxajdil4hq63tdga5slf7atzmjru6ochuq6e5pfk3phpilnh3dq]
module.vcn.oci_core_nat_gateway.nat_gateway[0]: Destroying... [id=ocid1.natgateway.oc1.ap-sydney-1.aaaaaaaaz6me23hdnjmm6wwj5jzvzrdzyixzudrcw7wz4aj7xx3d6w2jn5bq]
module.vcn.oci_core_route_table.ig[0]: Destruction complete after 0s
module.vcn.oci_core_internet_gateway.ig[0]: Destroying... [id=ocid1.internetgateway.oc1.ap-sydney-1.aaaaaaaaaj2chi3wsveij5mtotea3okp2z5y2ftagcaja6w6w56uzu5dpaba]
module.vcn.oci_core_internet_gateway.ig[0]: Destruction complete after 1s
module.vcn.oci_core_nat_gateway.nat_gateway[0]: Destruction complete after 1s
module.vcn.oci_core_service_gateway.service_gateway[0]: Destruction complete after 8s
module.vcn.oci_core_vcn.vcn: Destroying... [id=ocid1.vcn.oc1.ap-sydney-1.amaaaaaassl65iqazo5qhz2shgicdn6gwg3o7w4rpq6wz33ywwae3urf3mcq]
module.vcn.oci_core_vcn.vcn: Destruction complete after 0s

Destroy complete! Resources: 8 destroyed.

コンソールでも削除されたことが確認できます。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1