Skip to content

Generate Terraform Files from Existing AWS infrastructure

Notifications You must be signed in to change notification settings

al3v/Terraformer-AWS-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

Terraformer-AWS-Project

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

Animation



Prerequisites 🧰

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.



Installation 🐾

Installing Terraformer💫

  1. 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

  2. Add the path to the Terraformer executable file to the environmental variables' "Path" variable on your local system.















  1. 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
  1. Configure AWS CLI
 aws configure

image

  1. Navigate into the folder and ensure that the version.tf file is present

image

  1. Run 🖱️
 terraform init

image

  1. Run 🖱️( Here are alternative commands you can use)

 terraformer import aws --resources=vpc,subnet --regions=eu-west-1

image

  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

Result ✨

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.

image

About

Generate Terraform Files from Existing AWS infrastructure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages