This project offers a guide and scripts for using Terraformer to import your existing AWS infrastructure into Terraform configuration files. Terraformer is a CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform). This process allows for a seamless transition to managing your infrastructure as code using Terraform
✅ AWS CLI: Make sure you have the AWS CLI installed and configured with the necessary access rights to your AWS resources.
✅ Terraform: Ensure you have Terraform installed on your machine. Terraform is required to manage the generated files and apply changes.
-
After installing Terraform, Download exe file for the required cloud provider from here. In our case, it is windows amd64.
source: https://github.com/GoogleCloudPlatform/terraformer/tree/master?tab=readme-ov-file#installation -
Add the path to the Terraformer executable file to the environmental variables' "Path" variable on your local system.
- Create a folder📂(AWS to Terraform) and within it, create a file named "version.tf"📄 to install the plugins required for your platform. For example, in our case we need plugins for the AWS Cloud so versions.tf should contain:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.41.0"
}
}
required_version = ">= 0.13"
}
or git clone this repo
git clone https://github.com/al3v/Terraformer-AWS-Project.git
- Configure AWS CLI
aws configure
- Navigate into the folder and ensure that the version.tf file is present
- Run 🖱️
terraform init
- Run 🖱️( Here are alternative commands you can use)
terraformer import aws --resources=vpc,subnet --regions=eu-west-1
- To import all resources
terraformer import aws --resources="*" --regions=eu-central-1
To exclude some resources:
terraformer import aws --resources="*" --excludes=identitystore --regions=eu-central-1
In your folder(AWS to Terraform), you will find a subfolder named generated where you can locate separate subfolders for your "vpc.tf" and "subnet.tf" files.