# cloudtechner/ct-terraformer-automation architecture

> Architecture diagram of the GitHub repository cloudtechner/ct-terraformer-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloudtechner/ct-terraformer-automation
- Repository: https://github.com/cloudtechner/ct-terraformer-automation

## Overview

##### Project type and purpose
- This is a small automation tool (“open-source tool” style) that orchestrates Terraformer imports of cloud resources into Terraform code and then merges Terraform state files.
- Purpose: simplify “infrastructure as code” workflows by wrapping the Terraformer CLI and Terraform state-merge operations in scripts.

##### File structure
- Top level:
- README.md – usage guide
- requirements.txt – Python dependencies
- terraformer-variables-automation.py – main orchestration script (Python)
- tfstate-merge.sh – helper to merge Terraform state files (Bash)
- No frontend/backend split – it’s a CLI-only tool.
- External dependencies: Terraformer CLI, Terraform CLI, AWS API (via Terraformer).

##### Key insights from the README
- Users install Python deps, run the Python script to import resources, then run the shell script to merge .tfstate.
- Generated code lands under a “generated/<provider>/<resource>/” directory tree.

##### Essential details
- Clearly separate “import” vs “merge” workflows as two sub-flows.
- Where `requirements.txt` and environment setup occur (Python runtime).
- Dependency flow: Python → Terraformer → AWS → HCL + JSON → Bash → Terraform CLI → consolidated state.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users
    User("User (CLI)")
    click User "https://github.com/cloudtechner/ct-terraformer-automation/blob/main/README.md"

    subgraph "Import Workflow"
        direction TB
        PythonScript["Python Orchestration Script"]:::internal
        click PythonScript "https://github.com/cloudtechner/ct-terraformer-automation/blob/main/terraformer-variables-automation.py"
        TerraformerCLI["Terraformer CLI"]:::external
        AWSAPI["AWS API"]:::external
        GeneratedOutput["Generated Code & .tfstate\n(generated/<provider>/<resource>/)"]:::storage
        requirements["Python Dependencies\n(requirements.txt)"]:::internal
        click requirements "https://github.com/cloudtechner/ct-terraformer-automation/blob/main/requirements.txt"
    end

    subgraph "Merge Workflow"
        direction TB
        MergeScript["Shell Merge Script"]:::internal
        click MergeScript "https://github.com/cloudtechner/ct-terraformer-automation/blob/main/tfstate-merge.sh"
        TerraformCLI["Terraform CLI"]:::external
        ConsolidatedState["Consolidated .tfstate"]:::storage
    end

    %% Import Flow
    User -->|"invokes"| PythonScript
    PythonScript -->|"calls"| TerraformerCLI
    TerraformerCLI -->|"queries"| AWSAPI
    AWSAPI -->|"responds"| TerraformerCLI
    TerraformerCLI -->|"emits HCL + JSON"| GeneratedOutput
    GeneratedOutput -->|"picked up by"| PythonScript

    %% Merge Flow
    User -->|"invokes"| MergeScript
    MergeScript -->|"calls state subcommands on"| TerraformCLI
    TerraformCLI -->|"merges files into"| ConsolidatedState

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:1px
```
