Skip to content

About

Reverse Engineering Existing Infrastructure in Terraform | Reversing IaC

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

TerraReverse

Welcome to TerraReverse, an open-source tool designed to automatically reverse engineer Terraform code from existing infrastructure.

Overview

TerraReverse simplifies infrastructure management by translating your current deployments into reusable Terraform code. Whether you're migrating to Infrastructure as Code or documenting existing environments, TerraReverse helps bridge the gap between manually created infrastructure and code-defined resources.

Features

  • Multi-provider support: Extensible architecture for various infrastructure platforms
  • Accurate translation: Convert existing resources into HCL (HashiCorp Configuration Language)
  • Modular design: Each provider in its own module for easy maintenance
  • CLI interface: Simple command-line tool for seamless integration
  • Resource mapping: Automatically identify and map resources with their appropriate Terraform providers
  • Auto-import state: Experimental feature for importing existing resource states (see CRASH_REPORT.md for known issues)

Supported Providers

TerraReverse currently supports the following infrastructure provider:

Provider Resources Documentation
Proxmox Pools, Virtual Machines providers/proxmox/README.md

Additional providers can be added following our contribution guidelines.

Known Issues

Please review CRASH_REPORT.md for critical issues with the Terraform provider auto-import functionality.

Technical Stack

TerraReverse is built using:

  • Go: High-performance core functionality with modular provider architecture
  • Cobra CLI: Professional command-line interface
  • Provider APIs: Direct integration with infrastructure APIs

The modular architecture allows for easy extension and maintenance of provider-specific implementations.

Getting Started

Prerequisites

  • Go 1.21+
  • Access to your infrastructure provider (API credentials)
  • Terraform CLI (optional, for validating generated code)

Installation

From Go Package Registry

# Install the latest version
go install github.com/your-username/terrareverse@latest

# Install a specific version
go install github.com/your-username/[email protected]

From Source

# Clone the repository
git clone https://github.com/your-username/terrareverse.git
cd terrareverse

# Build the application
go build -o terrareverse .

Check Version

# Check installed version
terrareverse version

Quick Start

# List available providers
./terrareverse provider

# Get help for a specific provider
./terrareverse provider proxmox

# Generate all Proxmox resources (using username/password)
./terrareverse --provider proxmox --resource all \
               --url https://your-proxmox.com:8006 \
               --username root@pam \
               --password your-password \
               --output ./terraform-output

# Generate only VMs for Proxmox (using API token - recommended)
./terrareverse --provider proxmox --resource vm \
               --url https://your-proxmox.com:8006 \
               --token-id your-token-id \
               --secret your-token-secret \
               --output ./terraform-output

# Generate with auto-import (experimental - see known issues)
./terrareverse --provider proxmox --resource all \
               --url https://your-proxmox.com:8006 \
               --token-id your-token-id \
               --secret your-token-secret \
               --output ./terraform-output \
               --auto-import-state

# Generate multiple specific resource types
./terrareverse --provider proxmox --resource pool,vm \
               --url https://your-proxmox.com:8006 \
               --token-id your-token-id \
               --secret your-token-secret \
               --output ./terraform-output

Provider-Specific Documentation

Each provider has detailed documentation in its respective folder:

For more detailed usage instructions, see the provider-specific documentation.

Architecture

TerraReverse follows a modular provider-based architecture:

providers/
├── interface.go          # Generic provider interface
└── {provider}/           # Provider-specific implementation
    ├── README.md         # Provider documentation
    ├── client.go         # API client
    ├── provider.go       # Provider implementation
    ├── generator.go      # Provider-specific generation logic
    ├── templates.go      # Template processor
    ├── templates/        # Terraform template files
    └── {resource}.go     # Resource handlers

internal/
└── shared/
    └── utils.go          # Shared utilities (name sanitization, etc.)

Contributing

We welcome contributions! Whether you want to:

  • Add support for a new infrastructure provider
  • Improve existing provider functionality
  • Fix bugs or enhance documentation
  • Add new features to the core system

Please see our CONTRIBUTING.md guide for detailed instructions on how to contribute to TerraReverse.

Release Process

This project uses automated releases through GitHub Actions:

  1. Version Calculation: Uses GitVersion with semantic versioning
  2. Automated Testing: All PRs and pushes are automatically tested
  3. Release Creation: Pushes to master branch trigger automatic releases
  4. Package Registry: New versions are automatically published to pkg.go.dev
  5. Multi-platform Builds: Binaries are built for Linux, macOS, and Windows

Manual Release Steps

If you need to create a manual release:

# Ensure you're on master and up to date
git checkout master
git pull origin master

# Push to trigger the release workflow
git push origin master

# The GitHub Action will:
# 1. Calculate version using GitVersion
# 2. Create and push a git tag
# 3. Build cross-platform binaries
# 4. Create a GitHub release
# 5. Trigger pkg.go.dev to index the new version

Current Architecture

TerraReverse uses a modular provider-based architecture where each infrastructure provider is implemented as a separate module, making it easy to add support for new platforms.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • HashiCorp for creating Terraform
  • All contributors who have helped shape this project

Start your Infrastructure as Code journey today with TerraReverse!

About

Reverse Engineering Existing Infrastructure in Terraform | Reversing IaC

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages