How can I start managing already existing cloud resources using terraform?

Currently, we have a set of Terraforms which are being used to deploy resources to AWS cloud for our cloud infrastructure. We also have some old infrastructure in AWS which was not built using Terraform, and hence we do not have any terraform state files for those cloud resources. We are exploring how we can start managing these old non-terraform built cloud resources using our current set of terraforms.

Our idea is to explore:

  • if we can align whatever is there in the cloud(old non-terraform built resources) with our set of terraforms.
  • capture the current state of these resources in a terraform state files so that we can start managing these using terraforms.

Does this seem to be a reasonable approach? Any recommendations on how exactly this should be done and/or if there are any alternative approaches?

have you tried this?

1 Like

Thanks @ausmartway, wasn’t aware of this!

Importing existing resources to Terraform has come a long way in recent years. (@ausmartway is absolutely right to point to Terraformer; they filled a gap that existed in just about everyone’s use of Terraform for many years.) Now, in addition to generating state for any infrastructure you ask Terraform to import, it can optionally generate corresponding HCL as well, with the -generate-config-out flag.

Check out the relevant documentation, and a tutorial to practice, for more details. Good luck!

2 Likes