Describing Infrastructure

Create Terraform configuration files for the OCI Terraform provider.

Terraform uses declarative syntax to describe your Oracle Cloud Infrastructure (OCI) infrastructure and then persist it in configuration files that can be shared, reviewed, edited, versioned, preserved, and reused. Use Terraform configurations to define your OCI resources, data sources, variable definitions, and more.

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.

Terraform uses these configurations to make calls against Oracle Cloud Infrastructure API endpoints.

You can create configurations in several ways:

Tip

Whichever method you use to create Terraform configuration files, you should refer to Best Practices and the Services Reference for guidance on editing and maintaining your configurations for production use.

Using Resource Discovery

You can use the OCI Terraform provider's resource discovery feature to discover your deployed resources in a compartment and export them to Terraform configuration and state files. With a single command, you can generate files that capture your existing compartment's baseline configuration and state.

You can familiarize yourself with Terraform configurations by examining these output files. You can also use these output files to start using the Oracle Cloud Infrastructure Resource Manager.

For more information, see Resource Discovery.

Important

Resource discovery is not a migration tool. When cloning or migrating resources, configurations generated by resource discovery are a starting point. They may require changes.

Modifying Examples

There are many examples and solutions that you can use as a basis for describing your own infrastructure and understanding Terraform configuration files. See Examples, Templates, and Solutions for more information.

Authoring Your Own Configurations

If you're familiar with HashiCorp Configuration Language format (HCL) and Terraform configuration files, you can write your own. See Authoring Configurations for more information.