# m0hitd/aws-api-gateway-bluegreen architecture

> Architecture diagram of the GitHub repository m0hitd/aws-api-gateway-bluegreen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m0hitd/aws-api-gateway-bluegreen
- Repository: https://github.com/m0hitd/aws-api-gateway-bluegreen

## Overview

This repository describes an AWS API Gateway blue/green deployment system. A developer push triggers a GitHub Actions rollout: Terraform manages infrastructure, a candidate is deployed to green, traffic is shifted gradually, CloudWatch alarms gate promotion, and unhealthy releases roll back. The checked-in Lambda handlers show distinct blue and green responses. Infrastructure and workflow details beyond the sampled handlers are based on the README and file tree, not inspected implementation excerpts.

Main entry points: [`terraform/main.tf`](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf) (Terraform), [`src/blue/handler.py`](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/blue/handler.py) (Blue Lambda), [`src/green/handler.py`](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/green/handler.py) (Green Lambda), [`.github/workflows/deploy.yml`](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/.github/workflows/deploy.yml) (GitHub Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Deployment control"]
  node_actions["GitHub Actions<br/>[deploy.yml]"]
  node_terraform["Terraform<br/>[main.tf]"]
  node_canary["Canary deploy<br/>[canary-deploy.ps1]"]
end

subgraph group_gateway["Request serving"]
  node_dns["Route 53<br/>[main.tf]"]
  node_api["API Gateway<br/>[main.tf]"]
  node_blue_stage["Blue stage<br/>[main.tf]"]
  node_green_stage["Green stage<br/>[main.tf]"]
  node_blue_lambda["Blue Lambda<br/>[handler.py]"]
  node_green_lambda["Green Lambda<br/>[handler.py]"]
  node_aliases["Lambda aliases<br/>[main.tf]"]
end

subgraph group_monitoring["Observability"]
  node_cloudwatch["CloudWatch alarms<br/>[main.tf]"]
  node_metrics["Runtime metrics"]
end

subgraph group_state["Shared state"]
  node_dynamodb[("DynamoDB<br/>[main.tf]")]
  node_s3data[("Shared S3<br/>[main.tf]")]
  node_tfstate[("Terraform state<br/>[main.tf]")]
end

node_developer(("Developer"))
node_clients(("Public clients"))

node_developer -->|"pushes to main"| node_actions
node_actions -->|"applies infrastructure"| node_terraform
node_actions -->|"orchestrates rollout"| node_canary
node_terraform -->|"provisions"| node_api
node_terraform -->|"provisions"| node_blue_lambda
node_terraform -->|"provisions"| node_green_lambda
node_terraform -->|"configures alarms"| node_cloudwatch
node_terraform -->|"provisions"| node_dynamodb
node_terraform -->|"provisions"| node_s3data
node_terraform -->|"stores state"| node_tfstate
node_clients -->|"requests service"| node_dns
node_dns -->|"resolves to"| node_api
node_api -->|"serves stage"| node_blue_stage
node_api -->|"serves stage"| node_green_stage
node_blue_stage -->|"invokes alias"| node_aliases
node_green_stage -->|"invokes alias"| node_aliases
node_aliases -->|"routes traffic"| node_blue_lambda
node_aliases -->|"weights traffic"| node_green_lambda
node_blue_lambda -.->|"accesses shared data"| node_dynamodb
node_blue_lambda -.->|"accesses shared data"| node_s3data
node_green_lambda -.->|"accesses shared data"| node_dynamodb
node_green_lambda -.->|"accesses shared data"| node_s3data
node_blue_lambda -->|"emits"| node_metrics
node_green_lambda -->|"emits"| node_metrics
node_metrics -->|"evaluates alarms"| node_cloudwatch
node_canary -->|"shifts weights"| node_aliases
node_canary -->|"checks health"| node_cloudwatch

click node_actions "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/.github/workflows/deploy.yml"
click node_terraform "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_canary "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/scripts/canary-deploy.ps1"
click node_dns "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_api "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_blue_stage "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_green_stage "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_blue_lambda "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/blue/handler.py"
click node_green_lambda "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/green/handler.py"
click node_aliases "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_cloudwatch "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_dynamodb "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_s3data "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"
click node_tfstate "https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_actions,node_terraform,node_canary,node_clients toneBlue
class node_dns,node_api,node_blue_stage,node_green_stage,node_blue_lambda,node_green_lambda,node_aliases toneAmber
class node_cloudwatch,node_metrics toneMint
class node_dynamodb,node_s3data,node_tfstate toneRose
class node_developer toneIndigo
```

## Components

### Deployment control

- [GitHub Actions](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/.github/workflows/deploy.yml): `.github/workflows/deploy.yml`
- [Terraform](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Canary deploy](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/scripts/canary-deploy.ps1): `scripts/canary-deploy.ps1`

### Request serving

- [Route 53](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [API Gateway](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Blue stage](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Green stage](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Blue Lambda](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/blue/handler.py): `src/blue/handler.py`
- [Green Lambda](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/src/green/handler.py): `src/green/handler.py`
- [Lambda aliases](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`

### Observability

- [CloudWatch alarms](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- **Runtime metrics**

### Shared state

- [DynamoDB](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Shared S3](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`
- [Terraform state](https://github.com/m0hitd/aws-api-gateway-bluegreen/blob/main/terraform/main.tf): `terraform/main.tf`

### Other components

- **Developer**
- **Public clients**

## Connections

- Developer → GitHub Actions: pushes to main
- GitHub Actions → Terraform: applies infrastructure
- GitHub Actions → Canary deploy: orchestrates rollout
- Terraform → API Gateway: provisions
- Terraform → Blue Lambda: provisions
- Terraform → Green Lambda: provisions
- Terraform → CloudWatch alarms: configures alarms
- Terraform → DynamoDB: provisions
- Terraform → Shared S3: provisions
- Terraform → Terraform state: stores state
- Public clients → Route 53: requests service
- Route 53 → API Gateway: resolves to
- API Gateway → Blue stage: serves stage
- API Gateway → Green stage: serves stage
- Blue stage → Lambda aliases: invokes alias
- Green stage → Lambda aliases: invokes alias
- Lambda aliases → Blue Lambda: routes traffic
- Lambda aliases → Green Lambda: weights traffic
- Blue Lambda → DynamoDB: accesses shared data
- Blue Lambda → Shared S3: accesses shared data
- Green Lambda → DynamoDB: accesses shared data
- Green Lambda → Shared S3: accesses shared data
- Blue Lambda → Runtime metrics: emits
- Green Lambda → Runtime metrics: emits
- Runtime metrics → CloudWatch alarms: evaluates alarms
- Canary deploy → Lambda aliases: shifts weights
- Canary deploy → CloudWatch alarms: checks health
