# kareemcheez/aws-secure-stack architecture

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

- Interactive diagram: https://gitdiagram.com/kareemcheez/aws-secure-stack
- Repository: https://github.com/kareemcheez/aws-secure-stack

## Overview

This project is an AWS environment built with Terraform to deploy a secure-by-default AWS architecture. Its purpose is to enforce cloud best practices—specifically in security (IAM policies, AWS Config, SecurityHub, and optionally GuardDuty), cost control (budgets), logging (CloudTrail and S3 logging), and hosting a static site. The modularized Terraform structure indicates that each major component (IAM policies, logging, budgets, etc.) is encapsulated into a dedicated module, making it easier to manage and enable/disable features as needed.

##### Main Components
- Control Plane: The root Terraform configuration files (main.tf, variables.tf, outputs.tf, versions.tf) that wire the modules together.
- Modules: Each module represents a specific AWS resource or feature. The key modules include:
– IAM Policy – enforcing AWS account password and security rules.
– S3 Logging – creating an encrypted, versioned S3 bucket for logs.
– CloudTrail – capturing multi-region API event logs directed to the S3 bucket.
– Budgets – managing monthly budget alerts.
– Static Site – hosting a public static website on S3.
– Optionals (e.g., GuardDuty, AWS Config, SecurityHub) – which enhance security monitoring and compliance (these are disabled by default but can be enabled via terraform.tfvars).
- External Services: AWS Services such as S3, CloudTrail, IAM, AWS Budgets, and the AWS hosting environment.

##### Relationships and Interactions
- Modules may interact indirectly via shared resources (for example, CloudTrail’s logs are stored in the S3 Logging module’s bucket).
- Budget Alerts help monitor expenditures across the deployed resources.
- The static site may have dependencies on CloudFront (if used) or S3 bucket configuration for hosting, connecting it to domain management, if applicable.
- Optionally, when enabled, security modules such as SecurityHub, GuardDuty, and AWS Config work in tandem to provide comprehensive security posture monitoring, forming a feedback loop with the security policies enforced through IAM.

##### Architectural Patterns and Design Principles
- Modularity: The project’s folder structure shows clear separation of concerns with independent modules.
- Infrastructure as Code (IaC): Using Terraform declarative configurations for reproducibility and version control.
- Secure-by-default Setup: Emphasis on security (IAM policies, encrypted logging, monitoring via CloudTrail/SecurityHub) throughout the design.
- Optional/Feature Flags: Clear ability to enable or disable specific features like GuardDuty and AWS Config by configuration variables, providing flexibility based on cost or compliance requirements.

##### Relevant Technologies and Frameworks
- Terraform (v1.5+): For provisioning the AWS components.
- AWS Provider (v5+): To manage AWS services.
- AWS Services: S3 for logging and static site hosting, CloudTrail for auditing, AWS Budgets for financial control, and security services such as IAM, SecurityHub, GuardDuty, and AWS Config.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CP["AWS Secure Stack – Terraform Control Plane"]:::control
    subgraph "Core Modules"
        IAM["IAM Policy Module"]:::core
        S3["S3 Logging Module"]:::core
        CT["CloudTrail Module"]:::core
        SS["Static Site Module"]:::core
        BU["Budgets Module"]:::core
    end
    subgraph "Optional Security Modules"
        GD["GuardDuty Module"]:::optional
        AC["AWS Config Module"]:::optional
        SH["SecurityHub Module"]:::optional
    end

    %% Primary connections from Control Plane to modules
    CP -->|"initiates"| IAM
    CP -->|"initiates"| S3
    CP -->|"initiates"| CT
    CP -->|"initiates"| SS
    CP -->|"initiates"| BU
    CP -->|"initiates"| GD
    CP -->|"initiates"| AC
    CP -->|"initiates"| SH

    %% Inter-module relationships
    CT -->|"log_data_flow"| S3

    %% Budgets monitoring core modules
    IAM -->|"costUpdates"| BU
    S3 -->|"costUpdates"| BU
    CT -->|"costUpdates"| BU
    SS -->|"costUpdates"| BU

    %% Security feedback loop between IAM and Optional Security Modules
    IAM -->|"compliance"| GD
    IAM -->|"compliance"| AC
    IAM -->|"compliance"| SH

    GD -->|"alerts"| IAM
    AC -->|"alerts"| IAM
    SH -->|"alerts"| IAM

    %% Legend (as comments)
    %% Legend:
    %% Colors:
    %%   Control Plane: light red
    %%   Core Modules: light blue
    %%   Optional Security Modules: light green
    %% Arrow labels indicate relationship types without spaces

    %% Click Events
    click CP "https://github.com/kareemcheez/aws-secure-stack/blob/main/main.tf"
    click S3 "https://github.com/kareemcheez/aws-secure-stack/tree/main/modules/s3-logging/"
    click CT "https://github.com/kareemcheez/aws-secure-stack/tree/main/modules/cloudtrail/"
    click BU "https://github.com/kareemcheez/aws-secure-stack/tree/main/modules/budgets/"
    click SS "https://github.com/kareemcheez/aws-secure-stack/tree/main/modules/static-site/"
    click SH "https://github.com/kareemcheez/aws-secure-stack/tree/main/modules/securityhub/"

    %% Styles
    classDef control fill:#f9d4d4,stroke:#333,stroke-width:2px;
    classDef core fill:#cff4fc,stroke:#333,stroke-width:2px;
    classDef optional fill:#e2f0cb,stroke:#333,stroke-width:2px;
```
