X

The latest cloud infrastructure announcements, technical solutions, and enterprise cloud insights.

Two Tools to Bring Your Existing Infrastructure Under Terraform

Gaurav Jain
Product Lead, Developer Experience

IT infrastructure is moving to the cloud. Using an automation tool, such as Terraform, to manage this infrastructure is the norm today, but what if you didn’t start using Terraform from the beginning? This is the reality for many of our customers.

To build out their initial infrastructure, customers often use the Oracle Cloud Infrastructure Console or an SDK. As the infrastructure increases in scale and complexity, it becomes evident that it would be better managed programmatically, but it’s not always easy to bring existing infrastructure under Terraform. You’re often left with two options: discard the deployed infrastructure and re-create these resources using Terraform, or write in-house scripts to individually import resources into Terraform.

In a similar scenario, most managed service providers develop their own custom methods for managing their customers’ cloud. Having successfully completed this task, they want to replicate this infrastructure architecture for other customers. If the service provider hasn’t used Terraform from the beginning, this replication process is tedious.

We want to make this migration process less painful.

Oracle Cloud Infrastructure has two tools to help you manage your infrastructure programmatically: Terraform Provider and Resource Manager (our managed Terraform-as-a-service solution). Today we’re announcing two new features to help you bring your existing infrastructure to Terraform and Resource Manager: 

  • Terraform Resource Discovery helps you move from a console- or SDK-managed infrastructure to an infrastructure managed by Terraform.
  • State File Import helps customers who have a Terraform-managed infrastructure move to a Resource Manager–managed infrastructure.

Terraform Resource Discovery

You can use Terraform Resource Discovery to discover deployed resources in your compartment and export them to Terraform configuration and state files. This release supports the most commonly used Oracle Cloud Infrastructure services, such as Compute, Block Volumes, Networking, Load Balancing, Database, and Identity and Access Management (IAM). We’re continuously adding support for other Oracle Cloud services.

Use Cases and Benefits

With this feature, you can perform the following tasks:

  • Move from manually-managed infrastructure to Terraform-managed infrastructure: You can generate a baseline Terraform state file for your existing infrastructure with a single command, and manage this infrastructure by using Terraform.
  • Detect state drift: By managing the infrastructure using Terraform, you can detect when the state of your resources changes and differs from the desired configuration.
  • Duplicate or rebuild existing infrastructure: By creating Terraform configuration files, you can re-create your existing infrastructure architecture in a new tenancy or compartment.
  • Get started with Terraform: If you’re new to Terraform, you can learn about Terraform’s HCL syntax and how to represent Oracle Cloud Infrastructure resources in HCL.

Getting Started

To start using this feature, download the latest version of the terraform-oci-provider package by using the terraform init command or by going to the Terraform releases page. This feature is available for terraform-oci-provider 3.50 and later. To learn how to use this feature, see Discovering Terraform resources in an Oracle Cloud Infrastructure compartment.

State File Import for Resource Manager

State File Import lets you migrate your existing Terraform state files to Resource Manager. After you migrate, you can use Resource Manager to manage your entire fleet.

Use Cases and Benefits

  • Migrating from Terraform to Resource Manager: If you already use Terraform to manage Oracle Cloud Infrastructure resources, you can switch to Resource Manager without having to destroy any resources.
  • Leverage Terraform features that are currently unsupported by Resource Manager: Resource Manager doesn’t support all Terraform features, such as the ability to run jobs on specific resources or the ability to taint and untaint resources. Now, you can take advantage of such features by running the Terraform command locally, importing the generated state file, and updating Resource Manager with the current state.

Getting Started

To use Terraform features that aren’t supported by Resource Manager, follow these steps:

Note: When migrating Terraform to Resource Manager, perform only step 3.

  1. In Resource Manager, download the current state file from its Job Details page.

    Screenshot highlighting the Downlod Terraform State button on the Job Details page.

  2. Run the local Terraform command. This creates a new state file for use in step 3.
  3. Upload the new state file (and any updated configuration settings) to the Resource Manager stack by selecting the new Import State command from the Terraform Actions menu.

    Screenshot highlighting the Import State menu command.

Resources

If you’re new to Resource Manager or our Terraform Provider service, use the following resources to get started.

Resource Manager

Terraform

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha