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.
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:
- Use Resource Manager to see how Terraform represents your existing OCI resources.
- Use the OCI Terraform provider's resource discovery feature to create configuration files based on your existing OCI infrastructure.
- Copy and modify existing examples.
- Write your own Terraform configurations.
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.
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.
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.