aperswal / CloudFormation_To_Terraform

40 stars 6 forks source link

CloudFormation to Terraform Converter

Table of Contents

  1. Introduction
  2. Features
  3. Prerequisites
  4. Installation
  5. Usage
  6. Project Structure
  7. How It Works
  8. Customization
  9. Limitations
  10. Troubleshooting
  11. Contributing

Introduction

The CloudFormation to Terraform Converter is a tool that simplifies the process of migrating AWS CloudFormation templates to Terraform configuration files. This tool is designed for cloud engineers and DevOps professionals who are transitioning from AWS-specific infrastructure-as-code to a more cloud-agnostic approach using Terraform.

Features

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/aperswal/CloudFormation_To_Terraform.git
    cd CloudFormation_To_Terraform
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt

Usage

Web Application

  1. Start the Flask server:

    python app.py
  2. Open a web browser and navigate to http://localhost:5000

  3. Click on the "Pick Your Files" button and select your CloudFormation template(s) or a ZIP file containing multiple templates.

  4. The conversion will start automatically, and you'll receive a ZIP file with the converted Terraform files.

Command-Line Interface

  1. Run the CLI converter:

    python cli_converter.py <input_path> [-o <output_directory>]

    Examples:

    python cli_converter.py my_template.yaml
    python cli_converter.py my_templates_folder
    python cli_converter.py my_templates.zip -o converted_terraform
  2. The converted files will be placed in the specified output directory (or converted_files by default).

Project Structure

CloudFormation_To_Terraform/
│
├── app.py                 # Main Flask application
├── cli_converter.py       # Command-line interface for conversion
├── cf_to_tf_converter.py  # Core conversion logic
├── templates/
│   └── index.html         # Main page template
├── static/
│   └── css/
│       └── styles.css     # (Optional) Additional styles
├── requirements.txt       # Python dependencies
└── README.md              # This file

How It Works

  1. The user selects CloudFormation files through the web interface or specifies them via command line.
  2. Files are processed (either uploaded to the server or read locally).
  3. The cf_to_tf_converter.py script processes each file, converting CloudFormation syntax to Terraform.
  4. Converted files are either zipped and sent back to the user's browser (web interface) or saved to a local directory (CLI).
  5. Temporary files are cleaned up after processing.

Customization

Limitations

Troubleshooting

Contributing

Please see contributing.md