Jijin Shaji
Jijin Shaji

Reputation: 91

Taking backup of the built from OCI

I have used Terraform to built the instance and the resources in the OCI. Some I have done using the OCI console.

I would like to export all the built in some format to maintain that as a backup. In future if my instance or the resources gets changed accidentally or the corruption of data occurs, I need this export file to built the full environment.

Currently Terraform does not do the modification in the existing form while creating or doing changes in the instance or resource. It overwrites and changes everything, all the modification done in the OCI is reverted back if they are done using OCI console.

So please suggest me a way to export the current complete built. And any other scripting way to be followed for building the OCI.

Upvotes: 2

Views: 270

Answers (1)

Alex Ng
Alex Ng

Reputation: 11

In Terraform, your configuration file is always going to be the source of truth. When you apply your configuration the first time, Terraform stores the state of the created resources in a state file.

If you make changes to the resources in OCI console, Terraform will not know about them until the next time you run "terraform apply". It will detect that the resources have changed. But it will also decide to apply your configuration file over your OCI console changes. It will also warn you about this first.

This is part of the expected contract of Terraform. You would need to update your configuration file to tell Terraform exactly how you want your infrastructure to look like.

Unfortunately, there is no tool that will currently take your OCI console changes and automatically update your configuration file.

The closest thing to this is the "terraform import" command. The import functionality is limited to updating your state file with resources that were created in OCI console; but does not update your configuration file.

Upvotes: 1

Related Questions