# brunico/aws-codepipeline-s3-codedeploy-linux architecture

> Architecture diagram of the GitHub repository brunico/aws-codepipeline-s3-codedeploy-linux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brunico/aws-codepipeline-s3-codedeploy-linux
- Repository: https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux

## Overview

##### Project type and purpose
- This is not a traditional full-stack application but a sample AWS CodePipeline pipeline configuration.
- Purpose: Demonstrate a “Simple Pipeline” that takes a zipped web asset (index.html + scripts + appspec.yml), stores it in S3, and deploys it to a Linux target using AWS CodeDeploy.

##### File structure
- Top-level:
- appspec.yml – CodeDeploy hook mappings
- dist/aws-codepipeline-s3-aws-codedeploy_linux.zip – packaged deployment artifact
- index.html – the web content to deploy
- scripts/ – CodeDeploy lifecycle hook scripts (install_dependencies, start_server, stop_server)
- scripts/* – will be referenced by appspec.yml as BeforeInstall/AfterInstall hooks
- .github/, LICENSE, CONTRIBUTING, etc. – repository governance files, not part of runtime architecture
- appspec.yml + scripts define the deployment behavior on each EC2 instance.

##### README for additional insights
- Confirms this is the official AWS Simple Pipeline walkthrough sample

##### Main components & relationships
a. Developer/GitHub (or other SCM)
– Commits/PRs trigger pipeline execution
b. AWS CodePipeline
– Source stage: monitors repository (GitHub/S3)
– Deploy stage: invokes AWS CodeDeploy
c. AWS S3 (Artifact Store)
– Stores the zip package produced by the Source stage
d. AWS CodeDeploy
– Application + Deployment Group pointing at one or more EC2 instances
– appspec.yml and scripts/ run on each instance in lifecycle hooks
e. EC2 Instances (Linux target)
– Pulls down the archive from S3
– Executes install_dependencies, stop_server, copy index.html, start_server

##### Architectural patterns and design principles
- Separation of concerns:
- Pipeline orchestration (CodePipeline)
- Artifact storage (S3)
- Deployment orchestration (CodeDeploy)
- Immutable on-instance deployment via zip + lifecycle scripts
- Declarative deployment:
- appspec.yml drives hook ordering
- Infrastructure as Code (implied if pipeline is set up via CloudFormation/Console)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Stage
    Dev["Developer / GitHub"]:::external
    Dev -->|"Push/Commit"| CP["AWS CodePipeline"]:::aws

    %% Artifact Storage
    CP -->|"Store .zip artifact"| S3["AWS S3 (Artifact Store)"]:::aws
    click S3 "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/blob/master/dist/aws-codepipeline-s3-aws-codedeploy_linux.zip"

    %% Deployment Orchestration
    CP -->|"Start deployment"| CD["AWS CodeDeploy"]:::aws

    %% EC2 Instances
    CD -->|"Deploy to EC2 instances"| EC2["EC2 Instances (Linux)"]:::awsInstance

    %% On-Instance Lifecycle Hooks
    subgraph "On-Instance Deployment" 
        direction TB
        AS["appspec.yml"]:::onInstance
        click AS "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/blob/master/appspec.yml"
        ID["install_dependencies"]:::onInstance
        click ID "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/tree/master/scripts/install_dependencies"
        SS["stop_server"]:::onInstance
        click SS "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/tree/master/scripts/stop_server"
        IH["index.html"]:::onInstance
        click IH "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/blob/master/index.html"
        ST["start_server"]:::onInstance
        click ST "https://github.com/brunico/aws-codepipeline-s3-codedeploy-linux/tree/master/scripts/start_server"
    end

    EC2 --> AS
    AS --> ID
    ID --> SS
    SS --> IH
    IH --> ST

    %% Styling
    classDef aws fill:#f69e29,stroke:#333,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef awsInstance fill:#c6f5c9,stroke:#333,stroke-width:1px;
    classDef onInstance fill:#9ad0f5,stroke:#333,stroke-width:1px;
```
