# hashicorp/terraform-aws-vault-enterprise-hvd architecture

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

- Interactive diagram: https://gitdiagram.com/hashicorp/terraform-aws-vault-enterprise-hvd
- Repository: https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd

## Overview

##### Project Type and Purpose
- It is a Terraform module focused on cloud infrastructure deployment.
- Its purpose is to provision and configure Vault Enterprise in AWS using a validated design pattern which includes integrated storage, auto-unseal (via AWS KMS), and load balancing.
- The README indicates prerequisites (existing VPC with private subnets, NAT gateways, KMS key, TLS assets, etc.) and outlines how Vault nodes are managed (auto join, initialization, unsealing).

##### Analyzing the File Structure
- Top-Level Files: Several Terraform files (e.g., compute.tf, data.tf, iam.tf, lb.tf, network-security.tf) indicate that the module is splitting responsibilities such as compute configuration, IAM, networking, and load balancing.
- Directories such as “examples” provide sample configurations demonstrating usage scenarios.
- The “templates” directory contains shell and JSON policy templates that are used to initialize or configure components (like installing Vault or setting policies).
- GitHub workflows and configuration files indicate automated testing/validation (e.g., terraform-validate.yml) but are peripheral to the architecture focus.

##### Key Components
a. AWS Cloud Infrastructure:
- VPC: Show the Virtual Private Cloud where all resources reside.

b. Vault Cluster:
- Auto Scaling Group (ASG): Represent how Vault EC2 instances are grouped, ensuring resilience.
- Launch Template: Indicate the template used to create instances.
- Vault Servers: Highlight that each instance is running Vault Enterprise and mention their role in forming the cluster (initial uninitialized state, then joining to form the cluster).
- Auto-Unseal: Mark the integration with AWS KMS for auto-unsealing.

c. Networking and Security:
- IAM Roles and Policies: Represent how IAM roles, instance profiles, and policies are utilized to grant permissions to resources (e.g., launching instances, accessing Secrets Manager, using KMS keys).

d. External Services and Dependencies:
- AWS Secrets Manager: Indicate that secrets such as the Vault license, TLS certificate material, etc., are retrieved at deployment.
- TLS Certificate & KMS: Show integration points where AWS KMS (for auto-unseal) and TLS assets are used to secure communications.

##### Important Architectural Patterns and Design Principles
- Infrastructure as Code (IaC): The entire deployment is managed through Terraform.
- Modularity: The separation of resources into different files (compute, IAM, networking) helps indicate modular design.
- High Availability: The use of multiple Availability Zones and an Auto Scaling group reinforces resilience.
- Security & Compliance: The design includes detailed IAM, security groups, and load balancing rules to ensure secure deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    T["Terraform Module (IaC)"]:::iac

    subgraph "AWS Cloud Infrastructure"
        VPC["VPC, Subnets & NAT Gateways"]:::infrastructure
    end

    IAM["IAM Roles & Policies"]:::security

    subgraph "Vault Cluster"
        ASG["Auto Scaling Group"]:::cluster
        LT["Launch Template"]:::cluster
        VS["Vault Servers (Vault Enterprise)"]:::cluster
    end

    LB["AWS Load Balancer"]:::networking
    KMS["AWS KMS (Auto-Unseal)"]:::external
    SSM["AWS Secrets Manager"]:::external
    EX["Example Deployment"]:::example

    T --> VPC
    T --> IAM
    T --> ASG
    T --> LB
    T --> EX

    ASG --> LT
    LT --> VS

    LB -->|"routes"| VS
    VPC -->|"hosts"| VS
    IAM -->|"authorizes"| VS
    VS -->|"unseals"| KMS
    VS -->|"fetches"| SSM

    click VPC "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/network-security.tf"
    click ASG "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/compute.tf"
    click LB "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/lb.tf"
    click IAM "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/iam.tf"
    click IAM "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/templates/vault-server-role.json.tpl"
    click IAM "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/templates/vault-server-role-policy.json.tpl"
    click VS "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/blob/main/templates/install-vault.sh.tpl"
    click EX "https://github.com/hashicorp/terraform-aws-vault-enterprise-hvd/tree/main/examples/default"

    classDef iac fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef infrastructure fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef cluster fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef networking fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef security fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef example fill:#ffeeba,stroke:#856404,stroke-width:2px;
```
