Provision and Manage Resources

Use Oracle Resource Manager or Terraform to deploy, remove, or change your resources in the cloud efficiently.

About Terraform State Files

Terraform stores state information to track your managed infrastructure resources, map the deployed resources to your configuration, track metadata, and improve performance for large infrastructure deployments.

By default, the terraform.tfstate file is stored on the local host. This default behavior is not optimal in IT environments where multiple users need to create and destroy the resources that are defined in a given configuration. To control deploying and managing resources in a multi-user environment, store the Terraform state files in Oracle Cloud Infrastructure Object Storage, and share the state files and lock files between all the users.

See Using the Object Store for Terraform State Files.

Create the Resources

After you set the variables in terraform.tfvars file, use the Terraform CLI to deploy the resources defined in the Terraform configuration.

Before you begin, ensure that your local machine has internet access. If your local machine is behind a firewall, use an appropriate proxy to allow Terraform to reach the internet.
  1. On the computer where you installed Terraform, go to the directory that contains the terraform.tfvars file.
  2. Initialize Terraform, by running the following command:
    terraform init
    The command downloads the oci provider plugin and sets up the directory for use by Terraform.
  3. Verify that the syntax of the configuration has no errors:
    terraform validate
  4. If a syntax error exists, then fix the error, and repeat the previous step.
    To debug problems, you can configure logging:
    • Set the log level by using the TF_LOG environment variable. The supported log levels are 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.
  5. Review the resources defined in the configuration.
    terraform plan
    The output shows the details of all the actions that are performed when you apply this configuration, and a summary as shown in the following example.
    Plan: 26 to add, 0 to change, 0 to destroy.

    Note:

    The number 26 in the message is an example. The actual number depends on the settings that you defined in your Terraform configuration.
  6. If you want to make any changes, edit the configuration, validate it, and review the revised plan.
  7. Create the resources:
    terraform apply
  8. At the prompt Do you want to perform these actions?, enter yes
    As Terraform creates each resource, it displays the status of the operation.

    When all the resources are created, the message Apply complete is displayed, along with the number of resources added, changed, and destroyed.

The output will show the Public IPs of the Tomcat Server deployed.

Note:

You can view this Terraform output at any time by running the command terraform output.