# nagarajurahul/terraform-aws-multi-az-vpc architecture

> Architecture diagram of the GitHub repository nagarajurahul/terraform-aws-multi-az-vpc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nagarajurahul/terraform-aws-multi-az-vpc
- Repository: https://github.com/nagarajurahul/terraform-aws-multi-az-vpc

## Overview

##### Main components
- VPC – The central boundary for all network resources.
- Public Subnets – Deployed across multiple AZs and hosting the Internet Gateway (and possibly the NAT Gateway).
- Private Subnets – Also spread across multiple AZs, which route outbound traffic via the NAT Gateway.
- Internet Gateway – Attached to the VPC to provide internet access for the public subnets.
- NAT Gateway (optional) – Used to route traffic from private subnets to the internet.
- Route Tables – Configured in the VPC for managing routing between subnets, to the Internet Gateway, and optionally the NAT Gateway.
- IPv6 Block – Show as an attribute or additional layer for the VPC and its subnets when IPv6 support is enabled.

##### Relationships and interactions
- The VPC encloses all components.
- Public subnets are connected directly to the Internet Gateway, allowing for direct internet access.
- Private subnets do not have a direct route to the Internet Gateway; instead, they funnel traffic through the NAT Gateway.
- Route Tables are applied to both public and private subnets and dictate routing paths.
- In an environment with IPv6 enabled, emphasize that both the VPC and subnets are assigned IPv6 CIDR blocks.
- Multi-AZ nature by drawing separate public and private subnets for each Availability Zone (AZ), highlighting the high-availability design.

##### Architectural patterns and design principles
- Separation of concerns: Clear distinction between public and private network areas.
- Scalability and future-proofing with IPv6 integration.

##### Incorporate relevant technologies
- Terraform – as the IAC tool used to manage the deployment.
- AWS – components like VPC, subnets, Internet Gateway, NAT Gateway, and Route Tables.
- (Optionally) AWS DNS support for naming.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Terraform Module as the entry point
    TM("Terraform Module"):::iac
    TM --> VPC

    %% VPC container and cross-cutting concerns
    VPC("VPC"):::networking
    click VPC "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/main.tf"
    VPC --> IPv6["IPv6 Block"]:::networking
    click IPv6 "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/variables.tf"
    VPC --> DNS["DNS/Tagging"]:::networking
    click DNS "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/outputs.tf"

    %% Multi-AZ Deployment subgraph under VPC
    subgraph "Multi-AZ Deployment"
        subgraph "Availability Zone 1"
            PS1("Public Subnet AZ1"):::networking
            click PS1 "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/subnets.tf"
            PVS1("Private Subnet AZ1"):::networking
            click PVS1 "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/subnets.tf"
        end
        subgraph "Availability Zone 2"
            PS2("Public Subnet AZ2"):::networking
            click PS2 "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/subnets.tf"
            PVS2("Private Subnet AZ2"):::networking
            click PVS2 "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/subnets.tf"
        end
    end

    %% Route Tables node
    RT("Route Tables"):::route
    click RT "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/routes.tf"
    
    %% Gateways
    NAT("NAT Gateway (optional)"):::gateway
    click NAT "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/main.tf"
    IG("Internet Gateway"):::gateway
    click IG "https://github.com/nagarajurahul/terraform-aws-multi-az-vpc/blob/main/main.tf"
    
    %% Connections from VPC to internal components
    VPC -->|"contains"| PS1
    VPC -->|"contains"| PVS1
    VPC -->|"contains"| PS2
    VPC -->|"contains"| PVS2
    VPC -->|"contains"| RT

    %% Subnet to Gateway Routing for Public Subnets
    PS1 -->|"direct"| IG
    PS2 -->|"direct"| IG

    %% Subnet to Gateway Routing for Private Subnets
    PVS1 -->|"via NAT"| NAT
    PVS2 -->|"via NAT"| NAT
    NAT -->|"to gateway"| IG

    %% Route Tables applied to Subnets
    RT -->|"applied_to"| PS1
    RT -->|"applied_to"| PS2
    RT -->|"applied_to"| PVS1
    RT -->|"applied_to"| PVS2

    %% IPv6 configuration applied to Subnets
    IPv6 -->|"assigned_to"| PS1
    IPv6 -->|"assigned_to"| PS2
    IPv6 -->|"assigned_to"| PVS1
    IPv6 -->|"assigned_to"| PVS2

    %% Styles
    classDef networking fill:#cce5ff,stroke:#007bff,stroke-width:2px,color:#000;
    classDef gateway fill:#d4edda,stroke:#28a745,stroke-width:2px,color:#000;
    classDef route fill:#fff3cd,stroke:#ffc107,stroke-width:2px,color:#000;
    classDef iac fill:#ead1dc,stroke:#c2185b,stroke-width:2px,color:#000;
```
