Build Terraform code for Large infrastructure code built outside Terraform

Hi Terraform Experts,

We have a vast infrastructure that is built outside terraform. Now we want to manage this entire infrastructure using Terraform.

We plan to use the ‘GitHub - aws-samples/aws2tf: aws2tf - automates the importing of existing AWS resources into Terraform and outputs the Terraform HCL code.’ tool, which creates terraform tf files. But the issue is this tool dumps all 'tf’s files into one directory. In addition, we want to define ‘’ and change the respective ‘tf’ code to use ‘’.

The idea is to write a custom tool that reads ‘terraform.tfstate’( which is generated by ‘aws2tf’ tool) and creates ‘’, and updates respective terraform ‘tf’ files to use variables. But we feel it might not be the right approach, and there might be a better way to do this.

Can you please let me know the recommended approach from Hashicorp for this issue?