Getting Started

Terraform is "infrastructure-as-code" software that allows you to define your Oracle Cloud Infrastructure (OCI) resources in files that you can persist, version, and share. These files describe the steps required to provision your infrastructure and maintain its desired state:

Resources can create OCI infrastructure objects such as virtual cloud networks or compute instances. Your first application of the configuration creates the objects, and subsequent applications can update or delete them.

Data sources represent read-only views of your existing OCI infrastructure.

Variables represent parameters for Terraform.

Caution

Terraform state files contain all resource attributes that are specified as part of configuration files. If you manage any sensitive data with Terraform, like database or user passwords or instance private keys, you should treat the state file itself as sensitive data. See Storing Sensitive Data for more information.

Installing the Provider

To use the Oracle Cloud Infrastructure (OCI) Terraform provider, you must install both Terraform and the OCI Terraform provider. You can install both Terraform and the OCI Terraform provider with yum, or directly download them from HashiCorp.

Government Cloud customers should follow the installation and configuration steps in Enabling FIPS Compatiblity.

Tip

You can use Resource Manager to preinstall the Oracle Cloud Development Kit on a Compute instance in your compartment. The Oracle Cloud Development Kit includes Terraform and the OCI Terraform provider, and preconfigures the required authorization.

After downloading and installing, you must configure the Terraform provider so that Terraform can interact with OCI resources.

Prerequisites for Installing and Using the Provider

  • An Oracle Cloud Infrastructure (OCI) account that has user credentials sufficient to execute a Terraform plan.
  • A user in that account.
  • Required keys and OCI IDs (OCIDs). For guidance, see Required Keys and OCIDs.
  • The correct Terraform binary file for your operating system. We recommend using Terraform version 0.12.20 or greater.

Installing from HashiCorp

Terraform and the OCI Terraform provider can be downloaded directly from HashiCorp.

Download and Install Terraform

Terraform is available for direct download from the HashiCorp download page. Ensure that you download the correct binary file for your system.

Download and Install the Provider

To use the latest version of the OCI Terraform provider, run terraform init from the directory that contains a configuration file with the provider "oci" { ... configuration block. The provider is automatically downloaded. Terraform configurations also allow you to specify a particular version of the OCI Terraform provider.

You can also download the Terraform provider directly to a location of your choice.

Installing with Yum

If you're running Oracle Linux 7, you can use yum to install Terraform and the OCI Terraform provider.

To use yum to install Terraform:

sudo yum-config-manager --enable ol7_developer
sudo yum install terraform

To use yum to install the Terraform provider:

sudo yum-config-manager --enable ol7_developer
sudo yum install terraform-provider-oci

Test the Terraform Installation

Open a terminal window and run the following command to test your installation:

terraform -v