Create the Terraform Resources

Provision the resources that you defined in the Terraform configuration.

Before you begin, ensure that your local machine has internet access. If your local machine is behind a firewall, set proxies to allow Terraform to reach the internet.
Complete the following steps in the root directory:
  1. Initialize Terraform:
    terraform init
    The command downloads the oci provider plugin and sets up the directory for use by Terraform.
  2. Verify that the syntax of the configuration has no errors:
    terraform validate
  3. If a syntax error exists, then fix the error, and repeat the previous step.

    To debug problems, you can enable logging:

    • Configure the log level by setting the TF_LOG environment variable to TRACE, DEBUG, INFO, WARN, or ERROR. The TRACE level is the most verbose.
    • Set the log file path by using the TF_LOG_PATH environment variable.
  4. Review the resources defined in the configuration.
    terraform plan
    The output shows the actions that are performed when you apply this configuration, as shown in the following example.
    Plan: 26 to add, 0 to change, 0 to destroy.
  5. If you want to make any changes, edit the configuration, validate it, and review the revised plan.
  6. Create the resources:
    terraform apply

    If the following error occurs, then run terraform init to download the latest provider plugin.

    Error: Failed to instantiate provider "oci" to obtain schema: Incompatible API version with plugin. Plugin version: versionNumber, Client versions: versionNumber

  7. Enter yes at the prompt: Do you want to perform these actions?
    For each resource, Terraform displays the status of the operation.
  8. When the resources are created, Apply complete is displayed in the output, along with the number of resources added, changed, and destroyed.
    Apply complete! Resources: 26 added, 0 changed, 0 destroyed.
    To view the list of attributes later, execute the command terraform show.
You can customize the topology by creating other resources, such as subnets, and creating services in each compartment.