# splunk-terraform/terraform-provider-signalfx architecture

> Architecture diagram of the GitHub repository splunk-terraform/terraform-provider-signalfx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/splunk-terraform/terraform-provider-signalfx
- Repository: https://github.com/splunk-terraform/terraform-provider-signalfx

## Overview

##### Project type and purpose
- This is an open-source Terraform provider plugin (“terraform-provider-signalfx”) written in Go.
- Purpose: automate management of Splunk Observability Cloud resources (dashboards, integrations, charts, etc.) via Terraform.

##### File structure
- Top level:
- main.go – entrypoint registering the provider with Terraform Plugin SDK
- signalfx/ – Go package implementing the Provider, Resources, Data Sources
- internal/ – layered libraries:
– common, convert: helper functions and type conversions
– definition: per-resource schema + CRUD wiring
– framework: testing & provider scaffolding, plugin-protocol glue
– tfextension: Terraform extension helpers (diagnostics, logging)
– tftest: acceptance and unit test harness
– providermeta, track, visual: metadata, telemetry, presentation support
- templates/, docs/, examples/ – codegen templates, user docs, usage examples
- .github/workflows, goreleaser.yml, GNUmakefile – CI/CD, linting, release automation

##### README for additional insights
- Confirms it uses Terraform 0.12+ Plugin SDK and Go 1.19+.
- Describes build/test/release workflows.
- Integration test harness calls real Splunk APIs (and AWS for CloudWatch).

##### Essential architectural elements
- Lane 1: Terraform Core
- Lane 2: Plugin Host & gRPC
- Lane 3: Plugin internals (sub-layers)
- Lane 4: External services
- Within Plugin internals, further subdivide into:
- Provider registration
- Definition & schema
- Conversion helpers
- API client
- Test harness

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlane: Terraform Core
    subgraph "Terraform Core"
        CLI["Terraform CLI"]:::core
    end

    %% Swimlane: Plugin Host & gRPC
    subgraph "Plugin Host & gRPC"
        GRPC["Terraform Plugin SDK / gRPC Interface"]:::sdk
        Host["Plugin Host"]:::sdk
    end

    %% Swimlane: Plugin Internals
    subgraph "Plugin Internals"
        subgraph "Provider Setup"
            Entrypoint["main.go"]:::plugin
            ProvReg["signalfx/provider.go"]:::plugin
            ProvWire["internal/definition/provider/provider.go"]:::plugin
        end
        subgraph "Resources & DataSources"
            Resources["signalfx/resource_signalfx_*.go"]:::plugin
            DataSources["signalfx/data_source_*.go"]:::plugin
            DefSchemas["internal/definition/<resource_or_datasource>/"]:::plugin
        end
        Convert["internal/convert"]:::plugin
        APIClient["internal/common/notification_api.go"]:::plugin
        SDKGlue["internal/framework/provider.go"]:::plugin
        Embed["internal/framework/embed/"]:::plugin
        TFExt["internal/tfextension/"]:::plugin
        Meta["internal/providermeta/ track/ visual/"]:::plugin
    end

    %% Swimlane: External Systems
    subgraph "External Systems"
        Splunk["Splunk Observability Cloud API"]:::external
        AWS["AWS (for tests)"]:::external
    end

    %% Swimlane: CI/CD & Tests
    subgraph "CI/CD & Tests"
        CI[".github/workflows / goreleaser.yml"]:::test
        UnitTest["internal/framework/fwtest/"]:::test
        AcceptTest["internal/tftest/"]:::test
        IntegrTest["internal/framework/integration/"]:::test
    end

    %% Runtime Flow
    User(("User")):::external -->|"runs terraform apply"| CLI
    CLI -->|"gRPC call over stdio"| GRPC
    GRPC --> Host
    Host --> Entrypoint
    Entrypoint --> ProvReg
    ProvReg --> ProvWire
    ProvWire --> Resources
    ProvWire --> DataSources
    Resources --> DefSchemas
    DataSources --> DefSchemas
    DefSchemas --> Convert
    Convert --> APIClient
    APIClient -->|"HTTP POST/GET"| Splunk
    Splunk -->|"HTTP response"| Convert
    Convert --> DefSchemas
    DefSchemas --> GRPC
    GRPC --> CLI

    %% Plugin SDK & Extensions
    Host --> SDKGlue
    SDKGlue --> Embed
    Entrypoint --> TFExt
    Entrypoint --> Meta

    %% Test Flow (dashed)
    CI -.-> UnitTest
    UnitTest -.-> AcceptTest
    AcceptTest -.-> IntegrTest
    IntegrTest -.-> Splunk
    IntegrTest -.-> AWS

    %% Click Events
    click Entrypoint "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/main.go"
    click ProvReg "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/signalfx/provider.go"
    click ProvWire "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/internal/definition/provider/provider.go"
    click Resources "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/signalfx/resource_signalfx_*.go"
    click DataSources "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/signalfx/data_source_*.go"
    click DefSchemas "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/definition/<resource_or_datasource>/"
    click Convert "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/convert/"
    click APIClient "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/internal/common/notification_api.go"
    click SDKGlue "https://github.com/splunk-terraform/terraform-provider-signalfx/blob/main/internal/framework/provider.go"
    click Embed "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/framework/embed/"
    click TFExt "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/tfextension/"
    click UnitTest "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/framework/fwtest/"
    click AcceptTest "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/tftest/"
    click IntegrTest "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/internal/framework/integration/"
    click CI "https://github.com/splunk-terraform/terraform-provider-signalfx/tree/main/.github/workflows/"

    %% Styles
    classDef core fill:#e0f7fa,stroke:#0288d1,color:#000
    classDef sdk fill:#b2ebf2,stroke:#0288d1,color:#000
    classDef plugin fill:#e8f5e9,stroke:#2e7d32,color:#000
    classDef external fill:#fff3e0,stroke:#f57c00,color:#000
    classDef test fill:#f3e5f5,stroke-dasharray: 5 5,stroke:#8e24aa,color:#000
```
