# templatemechanics/pulumi-aws-classic architecture

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

- Interactive diagram: https://gitdiagram.com/templatemechanics/pulumi-aws-classic
- Repository: https://github.com/templatemechanics/pulumi-aws-classic

## Overview

##### Project type and purpose
- This is an infrastructure-as-code tool built with Pulumi. It reads a user’s `config.yaml`, dynamically maps resource definitions to Pulumi AWS classes, applies naming conventions & secret resolution, and then provisions or fetches AWS resources.

##### File structure
- `__main__.py` – the CLI/entry point.
- `config.py` – defines data models (dataclasses) for the YAML schema and a generic factory/mapping layer that, given a resource type (e.g., “ec2.Vpc”), picks the correct Pulumi AWS class and feeds it the args.
- `awsclassic.py` – houses AWS-specific logic: name templating (team-service-env-region-resource), region abbreviations, existing-vs-new resource lookup, and secret resolution (`secret:`).
- `config.yaml` – the user’s declarative spec.
- `Pulumi.yaml` + `requirements.txt` – Pulumi stack metadata & Python deps.

##### README for additional insights
- The README describes the naming convention, resource-referencing (`ref:<name>.<attr>`), secret syntax (`secret:<key>`), and dynamic introspection of Pulumi AWS classes.

a. Main components
- **CLI/Entry Point** (`__main__.py`)
- **YAML Config Loader**
- **Schema & Mapper** (`config.py`)
- **AWS Logic & Naming** (`awsclassic.py`)
- **Pulumi Engine** (Pulumi Python SDK)
- **AWS Provider/API**
- **AWS Resources** (VPC, Subnet, EC2, etc.)
- **Pulumi Config Store** (for secrets)

b. Relationships & interactions
1. User runs `python -m project` or `pulumi up`.
2. **Entry Point** reads `config.yaml`.
3. Loader hands raw YAML to **Schema & Mapper** → yields typed resource definitions.
4. Each definition is passed to **AWS Logic** → applies naming conventions, resolves `existing` vs new, secret lookups via Pulumi config.
5. Resulting Pulumi resource calls are sent to the **Pulumi Engine**.
6. Pulumi Engine communicates with the **AWS Provider/API** to create/update/fetch resources.
7. Outputs flow back into resource references, enabling `ref:` linking.

c. Architectural patterns / design principles
- **Separation of concerns**: parsing (config loader), mapping (config.py), AWS naming/logic (awsclassic.py), orchestration (main).
- **Factory/Reflection**: dynamic introspection of Pulumi AWS packages to map resource type strings to classes.
- **Declarative model → imperative execution**: YAML → Python dataclasses → Pulumi API calls.
- **Dependency graph**: Pulumi tracks resource dependencies automatically via references.

d. Key technologies/frameworks
- Pulumi Python SDK (`pulumi`, `pulumi_aws`)
- YAML parsing (`pyyaml` or equivalent)
- Python dataclasses
- AWS APIs

##### Detailed element checklist
- Distinguish synchronous flows (config → code) versus eventual consistency (Pulumi → AWS).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User CLI\n(python -m project / pulumi up)"]:::external
    ConfigYAML["config.yaml"]:::artifact
    PulumiYAML["Pulumi.yaml"]:::artifact
    Req["requirements.txt"]:::artifact
    README["README.md"]:::artifact

    subgraph "Control Plane"
        Main["CLI/Entry Point\n__main__.py"]:::internal
        Loader["YAML Config Loader\n& Schema/Mapper\n(config.py)"]:::internal
        Logic["AWS Logic & Naming\n(awsclassic.py)"]:::internal
    end

    subgraph "Execution Plane"
        PulumiEngine["Pulumi Engine\n(Pulumi SDK)"]:::external
        ConfigStore["Pulumi Config Store"]:::external
        AWSProvider["AWS Provider/API"]:::external
        AWSResources["AWS Resources\n(VPC, Subnet, EC2...)"]:::external
    end

    User --> Main
    Main -->|"reads config.yaml"| Loader
    Main -->|"reads Pulumi metadata"| PulumiYAML
    Main -->|"reads dependencies"| Req
    Loader -->|"typed definitions"| Logic
    Logic -->|"resolve secrets & existing resources via"| ConfigStore
    Logic -->|"invoke Pulumi resource calls"| PulumiEngine
    PulumiEngine -->|"calls AWS API"| AWSProvider
    AWSProvider -->|"provisions/fetches resources"| AWSResources
    AWSResources -->|"returns attributes"| PulumiEngine
    PulumiEngine -->|"stores/retrieves secrets"| ConfigStore

    click Main "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/__main__.py"
    click Loader "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/config.py"
    click Logic "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/awsclassic.py"
    click PulumiYAML "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/Pulumi.yaml"
    click Req "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/requirements.txt"
    click README "https://github.com/templatemechanics/pulumi-aws-classic/blob/main/README.md"

    classDef internal fill:#BBDEFB,stroke:#0D47A1,stroke-width:1px
    classDef external fill:#C8E6C9,stroke:#1B5E20,stroke-width:1px
    classDef artifact fill:#ECEFF1,stroke:#37474F,stroke-width:1px
```
