tofu-controller
tofu-controller copied to clipboard
`tfctl import` command
There are many scenarios when we want to import the current tfstate of a Terraform object. Currently, importing can be done using the terraform import
command together with many manual steps.
Implementing tfctl import
command would simplify those steps.
Workflow:
A user issue the following command against an existing Terraform object, in this case my-aws-s3-bucket
.
tfctl import -n flux-system my-aws-s3-bucket
Behavior:
- the command would examine
tf/my-aws-s3-bucket
and look for its identifier. The object's identifier is vary from resource to resource. - then, the command would create a temp dir, generate a provider block, a resource block,
- the command would call
terraform init
andterraform import <resource>.this <identifyier>
to import the tfstate. - next, the command would gzip the
terraform.tfstate
file - finally, the command would call
kubectl
to create a Secret from the gzipped tfstate file, and apply it to the cluster.
@chanwit, is there any preferred workaround to perform import until this feature is unavailable? I appreciate any help you can provide.