# googlecloudplatform/terraformer architecture

> Architecture diagram of the GitHub repository googlecloudplatform/terraformer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/terraformer
- Repository: https://github.com/googlecloudplatform/terraformer

## Overview

Terraformer is a CLI for reverse-importing existing infrastructure into Terraform configuration and state. The documented workflow selects a provider and resources, optionally filters or plans the import, discovers remote objects, then writes HCL/JSON and state; optional capabilities include custom output layouts, remote GCS state, and connecting resources through remote state. Provider packages implement discovery across cloud, infrastructure, identity, monitoring, and developer-tool APIs. The README documents orchestration and output features, but their implementation is not present in the sampled source, so those links are shown at the documented subsystem level.

Main entry points: [`cmd/root.go`](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/root.go) (Command root), [`cmd/plan.go`](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/plan.go) (Plan command), [`cmd/import.go`](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/import.go) (Import command), [`main.go`](https://github.com/googlecloudplatform/terraformer/blob/master/main.go) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_entry["CLI entry<br/>[main.go]"]
  node_commands["Command root<br/>[root.go]"]
  node_importcmd["Import command<br/>[import.go]"]
  node_plancmd["Plan command<br/>[plan.go]"]
  node_provider_cmds["Provider commands"]
end

subgraph group_import["Import pipeline"]
  node_plan["Import plan"]
  node_selection["Resource selection"]
  node_discovery["Resource discovery"]
  node_conversion["Terraform conversion"]
end

subgraph group_providers["Provider integrations"]
  node_provider_adapters["Provider adapters<br/>[aws_provider.go]"]
  node_cloud_adapters["Cloud adapters<br/>[gcp_provider.go]"]
  node_saas_adapters["SaaS adapters"]
  node_other_adapters["Other adapters"]
end

subgraph group_output["Generated artifacts"]
  node_artifacts["Terraform files"]
  node_state["Terraform state"]
  node_remote_state["Remote state links"]
end

node_operator(("Operator"))
node_remote[("Infrastructure APIs")]
node_gcs[("GCS bucket")]

node_operator -->|"runs"| node_entry
node_entry -->|"starts"| node_commands
node_commands -->|"dispatches"| node_importcmd
node_commands -->|"dispatches"| node_plancmd
node_importcmd -->|"selects provider"| node_provider_cmds
node_plancmd -->|"defines scope"| node_selection
node_plancmd -->|"writes plan"| node_plan
node_plan -->|"guides import"| node_importcmd
node_provider_cmds -->|"passes options"| node_selection
node_selection -->|"limits resources"| node_discovery
node_discovery -->|"dispatches discovery"| node_provider_adapters
node_provider_adapters -->|"reads resources"| node_remote
node_cloud_adapters -->|"reads resources"| node_remote
node_saas_adapters -->|"reads resources"| node_remote
node_other_adapters -->|"reads resources"| node_remote
node_discovery -->|"provides objects"| node_conversion
node_conversion -->|"generates HCL/JSON"| node_artifacts
node_conversion -->|"generates state"| node_state
node_state -.->|"uploads optionally"| node_gcs
node_artifacts -.->|"connects optionally"| node_remote_state
node_gcs -.->|"provides state"| node_remote_state

click node_entry "https://github.com/googlecloudplatform/terraformer/blob/master/main.go"
click node_commands "https://github.com/googlecloudplatform/terraformer/blob/master/cmd/root.go"
click node_importcmd "https://github.com/googlecloudplatform/terraformer/blob/master/cmd/import.go"
click node_plancmd "https://github.com/googlecloudplatform/terraformer/blob/master/cmd/plan.go"
click node_provider_cmds "https://github.com/googlecloudplatform/terraformer/blob/master/cmd/provider_cmd_aws.go"
click node_provider_adapters "https://github.com/googlecloudplatform/terraformer/blob/master/providers/aws/aws_provider.go"
click node_cloud_adapters "https://github.com/googlecloudplatform/terraformer/blob/master/providers/gcp/gcp_provider.go"
click node_saas_adapters "https://github.com/googlecloudplatform/terraformer/blob/master/providers/datadog/datadog_provider.go"
click node_other_adapters "https://github.com/googlecloudplatform/terraformer/blob/master/providers/kubernetes/kubernetes_provider.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_commands,node_importcmd,node_plancmd,node_provider_cmds toneBlue
class node_plan,node_selection,node_discovery,node_conversion,node_remote,node_gcs toneAmber
class node_provider_adapters,node_cloud_adapters,node_saas_adapters,node_other_adapters toneMint
class node_artifacts,node_state,node_remote_state toneRose
class node_operator toneIndigo
```

## Components

### CLI workflow

- [CLI entry](https://github.com/googlecloudplatform/terraformer/blob/master/main.go): `main.go`
- [Command root](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/root.go): `cmd/root.go`
- [Import command](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/import.go): `cmd/import.go`
- [Plan command](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/plan.go): `cmd/plan.go`
- [Provider commands](https://github.com/googlecloudplatform/terraformer/blob/master/cmd/provider_cmd_aws.go): `cmd/provider_cmd_aws.go`

### Import pipeline

- **Import plan**
- **Resource selection**
- **Resource discovery**
- **Terraform conversion**

### Provider integrations

- [Provider adapters](https://github.com/googlecloudplatform/terraformer/blob/master/providers/aws/aws_provider.go): `providers/aws/aws_provider.go`
- [Cloud adapters](https://github.com/googlecloudplatform/terraformer/blob/master/providers/gcp/gcp_provider.go): `providers/gcp/gcp_provider.go`
- [SaaS adapters](https://github.com/googlecloudplatform/terraformer/blob/master/providers/datadog/datadog_provider.go): `providers/datadog/datadog_provider.go`
- [Other adapters](https://github.com/googlecloudplatform/terraformer/blob/master/providers/kubernetes/kubernetes_provider.go): `providers/kubernetes/kubernetes_provider.go`

### Generated artifacts

- **Terraform files**
- **Terraform state**
- **Remote state links**

### Other components

- **Operator**
- **Infrastructure APIs**
- **GCS bucket**

## Connections

- Operator → CLI entry: runs
- CLI entry → Command root: starts
- Command root → Import command: dispatches
- Command root → Plan command: dispatches
- Import command → Provider commands: selects provider
- Plan command → Resource selection: defines scope
- Plan command → Import plan: writes plan
- Import plan → Import command: guides import
- Provider commands → Resource selection: passes options
- Resource selection → Resource discovery: limits resources
- Resource discovery → Provider adapters: dispatches discovery
- Provider adapters → Infrastructure APIs: reads resources
- Cloud adapters → Infrastructure APIs: reads resources
- SaaS adapters → Infrastructure APIs: reads resources
- Other adapters → Infrastructure APIs: reads resources
- Resource discovery → Terraform conversion: provides objects
- Terraform conversion → Terraform files: generates HCL/JSON
- Terraform conversion → Terraform state: generates state
- Terraform state → GCS bucket: uploads optionally
- Terraform files → Remote state links: connects optionally
- GCS bucket → Remote state links: provides state
