# palakbhawsar98/terraform-notes architecture

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

- Interactive diagram: https://gitdiagram.com/palakbhawsar98/terraform-notes
- Repository: https://github.com/palakbhawsar98/terraform-notes

## Overview

##### Project type and purpose
- This is a hands-on Terraform tutorial repo (Infrastructure-as-Code) that demonstrates how to provision AWS resources (EC2 instances, VPCs, remote state).
- It is not a web application but a collection of Terraform modules/examples, each in its own folder, illustrating specific IaC use cases.

##### File structure
- Top-level demo scripts:
- terraform-ec2-hands-on      – EC2 provisioning example
- terraform-vpc-hands-on      – VPC + subnets + outputs
- terraform-remote-state-hands-on – remote state configuration
- Each folder contains .tf files:
- providers.tf, main.tf, variables.tf, outputs.tf, etc.
- No source code; all HCL configuration. No tests or CI/CD configs present.

##### README for additional insights
- Explains Terraform workflow (init, plan, apply)
- Describes providers, state, variables, lifecycle, outputs
- Mentions AWS provider, S3 backend options, typical resource blocks

a. Main components
- Developer workstation running Terraform CLI
- Terraform configuration files (.tf)
- Terraform State (local or remote backend e.g. S3)
- AWS Provider API
- AWS resources:
– VPC
– Subnets (multiple AZs)
– EC2 Instances
b. Relationships & data flow
1. Developer edits .tf files
2. terraform init loads provider plugin
3. terraform plan generates execution plan
4. terraform apply → CLI calls AWS Provider API
5. AWS API provisions VPC, subnets, EC2
6. Terraform writes state to backend (local file or S3)
7. Outputs are returned to CLI
c. Architectural patterns & design principles
- IaC pattern: declarative config → desired state
- State management: remote backend for collaboration/locking
- Module separation: each tutorial folder acts as its own isolated “module”
- Provider abstraction: Terraform plugin architecture
d. Key technologies
- Terraform Core (HCL)
- AWS Provider plugin
- Remote state backend (e.g. AWS S3)
- AWS VPC, EC2 APIs

##### Elements
- Labels:
- Terraform CLI
- Configuration Directory (with sub-folders)
- Remote State Backend (S3)
- AWS Provider
- AWS Resources (VPC, Subnet(s), EC2 Instances)
- From CLI to AWS Provider API (calls)
- From CLI to State Backend (read/write)
- Between resources (VPC → Subnets → EC2)
- Rectangles for components you control (CLI, config files)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workstation
    subgraph "Developer Workstation"
        TerraformCLI["Terraform CLI"]:::terraform
        ConfigDir["Configuration Directory"]:::terraform
    end

    %% Modules Directory
    subgraph "Configuration Directory (Modules)"
        subgraph "EC2 Module"
            EC2Main["main.tf"]:::module
            EC2Vars["variables.tf"]:::module
            EC2LocalFiles["local_files.tf"]:::module
        end
        subgraph "VPC Module"
            VPCProv["providers.tf"]:::module
            VPCVars["variables.tf"]:::module
            VPCTF["vpc.tf"]:::module
            VPCOut["outputs.tf"]:::module
        end
        subgraph "Remote State Module"
            RSMain["main.tf"]:::module
            RSOut["outputs.tf"]:::module
        end
    end

    %% Terraform Core Flow
    TerraformCLI -->|"reads .tf files"| ConfigDir
    TerraformCLI -->|"init/plan/apply"| AWSProvider
    TerraformCLI -->|"reads/writes state"| StateBackend

    %% AWS Provider and Resources
    AWSProvider["AWS Provider"]:::terraform
    AWSProvider -->|"provision VPC"| VPCResource["VPC"]:::aws
    VPCResource -->|"create Subnets"| SubnetResource["Subnet(s)"]:::aws
    SubnetResource -->|"launch EC2"| EC2Resource["EC2 Instance(s)"]:::aws

    %% State Backend
    StateBackend["State Backend (Local/S3)"]:::state

    %% Click Events
    click TerraformCLI "https://github.com/palakbhawsar98/terraform-notes/blob/main/README.md"
    click ConfigDir "https://github.com/palakbhawsar98/terraform-notes/blob/main/README.md"
    click EC2Main "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-ec2-hands-on/main.tf"
    click EC2Vars "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-ec2-hands-on/variables.tf"
    click EC2LocalFiles "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-ec2-hands-on/local_files.tf"
    click EC2Main "https://github.com/palakbhawsar98/terraform-notes/tree/main/terraform-ec2-hands-on/"
    click VPCProv "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-vpc-hands-on/providers.tf"
    click VPCVars "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-vpc-hands-on/variables.tf"
    click VPCTF "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-vpc-hands-on/vpc.tf"
    click VPCOut "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-vpc-hands-on/outputs.tf"
    click VPCProv "https://github.com/palakbhawsar98/terraform-notes/tree/main/terraform-vpc-hands-on/"
    click RSMain "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-remote-state-hands-on/main.tf"
    click RSOut "https://github.com/palakbhawsar98/terraform-notes/blob/main/terraform-remote-state-hands-on/outputs.tf"
    click RSMain "https://github.com/palakbhawsar98/terraform-notes/tree/main/terraform-remote-state-hands-on/"

    %% Styles
    classDef terraform fill:#D6EAF8,stroke:#2E86C1,color:#1B4F72
    classDef module fill:#FAD7A0,stroke:#D68910,color:#784212
    classDef aws fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef state fill:#F5CBA7,stroke:#D35400,color:#873600
```
