# zetaaztra/ec2_terraform architecture

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

- Interactive diagram: https://gitdiagram.com/zetaaztra/ec2_terraform
- Repository: https://github.com/zetaaztra/ec2_terraform

## Overview

##### Main Components
- Terraform Configuration Files – These include main.tf, provider.tf, variables.tf, and outputs.tf. They define your infrastructure (the EC2 instance) and configuration details such as the AWS provider, input variables, and outputs.
- GitHub Workflows – Found under the .github/workflows folder (files: Main.yml, aws_tf_apply.yml, aws_tf_plan.yml). These scripts automate Terraform commands (e.g., terraform plan and terraform apply) as part of your CI/CD pipeline.
- AWS Cloud Platform – The target environment where the EC2 instance is provisioned.

##### Relationships and Interactions
- The GitHub repository acts as the source of truth for your Terraform scripts.
- Changes pushed to the repository trigger GitHub Actions, which run the configured workflows.
- The workflows execute Terraform commands that read the Terraform configuration files.
- Terraform interacts with the AWS API (using the settings in provider.tf) to provision the EC2 instance as defined in main.tf.
- Outputs from Terraform (defined in outputs.tf) can be used to quickly reference important details about the provisioned resources.

##### Architectural Patterns and Design Principles
- Infrastructure as Code – All infrastructure configuration is codified, making your deployment repeatable and version-controlled.
- CI/CD Pipeline – Automated workflows via GitHub Actions ensure that the Terraform plan and apply process is consistent and less error-prone.
- Separation of Concerns – The division between Terraform configuration files and workflow automation scripts helps maintain clarity in the project’s responsibilities.

##### Relevant Technologies and Tools
- Terraform – The core engine that interprets the configuration files.
- GitHub Actions – The automation tool for CI/CD that runs the Terraform workflows.
- AWS – The cloud provider where the EC2 instance is created.

## Diagram (Mermaid)

```mermaid
graph TD
    Repo["Terraform IaC Repository"]:::repo

    subgraph "GitHub Actions Workflows (CI/CD Pipeline)"
        ghaMain["Main.yml"]:::workflow
        ghaApply["aws_tf_apply.yml"]:::workflow
        ghaPlan["aws_tf_plan.yml"]:::workflow
    end

    subgraph "Terraform Configuration Files"
        T_main["main.tf"]:::config
        T_provider["provider.tf"]:::config
        T_variables["variables.tf"]:::config
        T_outputs["outputs.tf"]:::config
    end

    Engine["Terraform Engine"]:::terraform
    AWS["AWS EC2 Instance"]:::aws

    Repo -->|"Triggers"| ghaMain
    Repo -->|"Triggers"| ghaApply
    Repo -->|"Triggers"| ghaPlan

    ghaMain -->|"Runs"| Engine
    ghaApply -->|"Runs"| Engine
    ghaPlan -->|"Runs"| Engine

    T_main -->|"ProvidesConfig"| Engine
    T_provider -->|"ProvidesConfig"| Engine
    T_variables -->|"ProvidesConfig"| Engine
    T_outputs -->|"ProvidesConfig"| Engine

    Engine -->|"Provisions"| AWS

    click T_main "https://github.com/zetaaztra/ec2_terraform/blob/main/main.tf"
    click T_provider "https://github.com/zetaaztra/ec2_terraform/blob/main/provider.tf"
    click T_variables "https://github.com/zetaaztra/ec2_terraform/blob/main/variables.tf"
    click T_outputs "https://github.com/zetaaztra/ec2_terraform/blob/main/outputs.tf"
    click ghaMain "https://github.com/zetaaztra/ec2_terraform/blob/main/.github/workflows/Main.yml"
    click ghaApply "https://github.com/zetaaztra/ec2_terraform/blob/main/.github/workflows/aws_tf_apply.yml"
    click ghaPlan "https://github.com/zetaaztra/ec2_terraform/blob/main/.github/workflows/aws_tf_plan.yml"

    classDef repo fill:#f9f,stroke:#333,stroke-width:2px;
    classDef workflow fill:#ccf,stroke:#333,stroke-width:2px;
    classDef config fill:#cfc,stroke:#333,stroke-width:2px;
    classDef terraform fill:#fc9,stroke:#333,stroke-width:2px;
    classDef aws fill:#fcc,stroke:#333,stroke-width:2px;
```
