boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

Implement import in terraspace #246

Closed gus-cash closed 2 years ago

gus-cash commented 2 years ago

Summary

Terraspace does not allow up to now to import already created resources

Motivation

The Import option is very important to be able to migrate projects to terraspace

Guide-level explanation

We want to import resources to a terraspace stack but we can't because the import option is not enabled

morey-tech commented 2 years ago

I have been migrating to Terraspace from Terraform/Terragrunt. My current workaround is to run the terraform import commands in the .terraspace-cache directory for the stack before running terraspace all up. For example:

terraspace all init  # this generates the `.terraspace-cache`.
cd .terraspace-cache/us-east1-a/live/stacks/dev
terraform import google_container_cluster.main my-gcp-project/us-east1-a/my-cluster
cd ../../../../../
terraspace all plan
terraspace all up

This is a crude example of the process. Implement with CI for best results.

It would however be great to have first-class support for this functionality. I do a lot of imports (and state removals) as the code base is refactored.