To create Terraform files based on the existing infrastructure, we will use Terraformer
In this example, the macOS system will be used, so we install terraformer using homebrew:
brew install terraformer
Installation for other OSs can be found on the project page.
Create a directory for storing plugins (for working with providers)
mkdir -p ~/.terraform.d/plugins/darwin_amd64
Terraform file generation examples
Create Terraform files for all S3 buckets and EC2 instances in the region: us-east-1
terraformer import aws --resources=s3,ec2_instance --regions=us-east-1
kubectl must be installed and configured
We find the most current version of the darwin version, download, unzip and move the contents of the archive to the previously created directory
Create Terraform files for all deployments, services and storageclasses
terraformer import kubernetes --resources=deployments,services,storageclasses
Lists of supported providers and resources can be found in more detail here.