# aws-samples/aws-refarch-wordpress architecture

> Architecture diagram of the GitHub repository aws-samples/aws-refarch-wordpress, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/aws-refarch-wordpress
- Repository: https://github.com/aws-samples/aws-refarch-wordpress

## Overview

##### What this project is (type + purpose)
This repo is not an “application codebase” in the classic sense; it’s an **AWS Reference Architecture** implemented as **AWS CloudFormation YAML templates** to deploy a **high-availability, scalable WordPress stack on AWS**.

Key indicators:
- `templates/aws-refarch-wordpress-master-newvpc.yaml` and many `aws-refarch-wordpress-0x-*.yaml` files → **nested CloudFormation stacks** orchestrated from a master template.
- README enumerates AWS resources: VPC/subnets/NAT/IGW, ALB, Auto Scaling Groups, EC2, RDS Aurora, EFS, ElastiCache (optional), CloudFront/Route53 (optional), ACM, CloudWatch dashboard/alarms, SNS notifications, bastion.
- `bits/` contains artifacts used at instance boot/config time (e.g., OPcache status PHP, ElastiCache client tarball).

##### How to read the file tree into architecture

- **`templates/`** = the authoritative architecture definition (CloudFormation).
- `aws-refarch-wordpress-master-newvpc.yaml` (and “master” variants) = orchestration / composition.
- `aws-refarch-wordpress-01-newvpc.yaml` = networking foundation (VPC, subnets, routing, NAT, IGW).
- `aws-refarch-wordpress-02-securitygroups.yaml` = security boundaries and allowed flows.
- `aws-refarch-wordpress-03-*` = core service layers (bastion, EFS, alarms, ElastiCache, ALB, RDS).
- `aws-refarch-wordpress-04-*` = edge + web tier (CloudFront, web ASG/EC2).
- `aws-refarch-wordpress-05-route53.yaml` = DNS.
- `aws-refarch-wordpress-06-dashboard.yaml` = observability.
- **`samples/`** = example parameters and “how to launch” scripts—useful to understand optional toggles (CloudFront/Route53/ElastiCache, etc.).
- **`bits/`** = runtime configuration payloads placed onto instances (OPcache status page, php.ini overrides sample referenced via S3 URL, etc.).

##### What

Master template as the root and each nested template as a child stack with clear responsibility boundaries.

Recommended nodes:
- **Master Stack**: `aws-refarch-wordpress-master-newvpc.yaml`
- **01 Networking**: VPC, public/web/data subnets across 2–6 AZs, route tables, IGW, NAT GW(s)
- **02 Security Groups**: ALB SG, Web SG, DB SG, EFS SG, Bastion SG, etc.
- **03 Bastion**
- **03 EFS File System**
- **03 EFS Alarms** (+ SNS notifications, autoscaling “threshold adjuster” instance)
- **03 RDS Aurora**
- **03 ElastiCache (optional)**
- **03 Public ALB**
- **04 Web Tier**
- **04 CloudFront (optional)**
- **05 Route53 (optional)**
- **06 CloudWatch Dashboard**

Why this matters: this repo’s architecture *is* the CloudFormation composition.

Include:
- **Client (Browser)**
- **Route 53** (optional) → **CloudFront** (optional) → **ALB (public subnets)**
- **ALB** → **Web Auto Scaling Group (EC2 in private web subnets)**
- Web EC2 runtime dependencies:
- **EFS** (private data subnets) mounted by web instances for shared WordPress content (e.g., wp-content)
- **RDS Aurora** (private data subnets) for WordPress database
- **ElastiCache Memcached** (optional) for object/page/db caching via plugin (W3 Total Cache)
- **OPcache** on each instance (local, per-node) + optional status page
- **Outbound path** from web instances to the internet via **NAT Gateway** (for OS updates, package downloads, WordPress/plugin updates, S3 access for offload, etc.)
- **Bastion Host** (public subnet) for SSH access into private instances

- HTTPS: Client → (Route53) → (CloudFront) → ALB
- HTTP/HTTPS: ALB → Web EC2
- NFS: Web EC2 ↔ EFS
- MySQL: Web EC2 ↔ Aurora
- Memcached: Web EC2 ↔ ElastiCache
- SSH: Admin → Bastion → Web EC2
- Egress: Web EC2 → NAT GW → Internet/AWS APIs

This repo is explicit about:
- **public subnets**: ALB, NAT GW, bastion
- **private web subnets**: WordPress EC2 in ASG
- **private data subnets**: RDS, EFS mount targets, ElastiCache

To be accurate:
- ALB spans public subnets in multiple AZs
- Web ASG has instances across private web subnets in multiple AZs
- EFS has mount targets per AZ (in data subnets)
- Aurora is multi-AZ (cluster depiction)
- NAT GW(s) in public subnets (README implies across public subnets)
- **route tables** at least conceptually:
- Public subnets route to IGW
- Private subnets route to NAT for egress

##### Relationships / interactions to highlight (project-specific)

1. **Shared filesystem is a first-class design choice**: Web instances are stateless-ish; **EFS centralizes WordPress files** so autoscaling doesn’t lose uploads/themes/plugins.
##### Compute is horizontally scalable: Web tier is an Auto Scaling Group behind an ALB.
3. **Data tier is managed**: **Aurora** for DB, **EFS** for file store, **ElastiCache** optional.
4. **Optional edge acceleration**: **CloudFront** (optionally with ACM cert in us-east-1) sits in front; Route53 optionally points at it or ALB.
5. **Operational maturity**: CloudWatch dashboard + EFS burst credit alarms + SNS notifications + special “threshold adjuster” automation via an EC2/ASG mechanism.
6. **Admin access pattern**: Bastion is present but “desired=0 by default” and can be enabled when needed.

##### Top: Client → Route53 → CloudFront (optional)
- Public subnets: ALB, NAT GW, Bastion
- Private web subnets: Web ASG instances
- Private data subnets: Aurora, ElastiCache, EFS mount targets
##### Bottom: CloudFormation master stack → nested stacks (small inset or side panel)

This yields a single page that is both “ops-accurate” and “design-communicative.”

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Diagram A: IaC Composition (Nested Stacks)
%% =========================
subgraph A["A) IaC Stack Composition (CloudFormation Nested Stacks)"]
direction TB

MS["Master Stack\n(Nested Orchestration)"]:::iac

subgraph A1["Core Nested Stacks (provisioning order)"]
direction TB
N1["01 Networking\n(VPC/Subnets/Routes/IGW/NAT)"]:::network
S2["02 Security Groups\n(Security Boundaries)"]:::security

B3["03 Bastion"]:::compute
EFS3["03 EFS File System\n(Shared wp-content)"]:::data
EFSAL3["03 EFS Alarms + SNS\n(Threshold Adjuster Automation)"]:::observability
RDS3["03 RDS Aurora\n(Database Tier)"]:::data
EC3["03 ElastiCache Memcached\n(optional)"]:::data
ALB3["03 Public ALB\n(Ingress)"]:::edge

WEB4["04 Web Tier\n(ASG / EC2 WordPress)"]:::compute
CF4["04 CloudFront Distribution\n(optional)"]:::edge

R53_5["05 Route 53 DNS\n(optional)"]:::edge
CW6["06 CloudWatch Dashboard\n(Observability)"]:::observability
end

MS -.->|"creates"| N1
N1 -.->|"then"| S2
S2 -.->|"then"| B3
S2 -.->|"then"| EFS3
EFS3 -.->|"then"| EFSAL3
S2 -.->|"then"| RDS3
S2 -.->|"then"| EC3
S2 -.->|"then"| ALB3
ALB3 -.->|"then"| WEB4
WEB4 -.->|"optional"| CF4
CF4 -.->|"optional"| R53_5
ALB3 -.->|"optional"| R53_5
MS -.->|"creates"| CW6
EFSAL3 -.->|"alarms_to"| CW6
end

%% =========================
%% Diagram B: Runtime Request & Data Flow (Vertical)
%% =========================
subgraph B["B) Runtime Request & Data Flow"]
direction TB

Client["Client Browser"]:::external

R53["Route 53\n(optional)"]:::edge
CF["CloudFront\n(optional)"]:::edge
ACM["ACM Certificate\n(optional, for TLS)"]:::security

ALB["Application Load Balancer\n(Public)"]:::edge

WEB["Web Auto Scaling Group\n(WordPress EC2)"]:::compute
OPC["OPcache\n(per-instance)"]:::compute

EFS["EFS\n(shared wp-content)"]:::data
RDS["Aurora (MySQL)\nWordPress DB"]:::data
MC["ElastiCache Memcached\n(optional)"]:::data

NAT["NAT Gateway"]:::network
IGW["Internet Gateway"]:::network
INET["Internet / AWS APIs"]:::external

Admin["Admin (SSH)"]:::external
Bastion["Bastion Host\n(desired=0 by default)"]:::compute

CW["CloudWatch Metrics/Dashboard"]:::observability
ALARM["CloudWatch Alarms\n(EFS burst credits etc.)"]:::observability
SNS["SNS Notifications"]:::observability
Adj["Threshold Adjuster\n(automation EC2/ASG)"]:::compute
KMS["KMS Key\n(optional encryption)"]:::security

Client -->|"HTTPS:443"| R53
R53 -->|"alias_to (optional)"| CF
R53 -->|"alias_to (optional)"| ALB
CF -->|"HTTPS:443"| ALB
ACM -.->|"cert_for"| CF
ACM -.->|"cert_for"| ALB

ALB -->|"HTTP/HTTPS:80/443"| WEB
WEB -->|"local_exec"| OPC

WEB <-->|"NFS:2049"| EFS
WEB <-->|"MySQL:3306"| RDS
WEB <-->|"Memcached:11211 (optional)"| MC

WEB -->|"egress"| NAT -->|"route"| IGW -->|"to"| INET

Admin -->|"SSH:22"| Bastion -->|"SSH:22"| WEB

CW -.->|"reads_metrics"| ALB
CW -.->|"reads_metrics"| WEB
CW -.->|"reads_metrics"| RDS
CW -.->|"reads_metrics"| EFS
ALARM -.->|"triggers"| SNS
ALARM -.->|"drives"| Adj

KMS -.->|"encrypts(optional)"| EFS
KMS -.->|"encrypts(optional)"| RDS
end

%% =========================
%% Diagram C: Network & Security Boundaries (2-AZ exemplar)
%% =========================
subgraph C["C) VPC / Subnets / AZs + Security Boundaries (example: 2 AZs)"]
direction TB

subgraph VPC["VPC (created by 01 Networking)"]
direction TB

subgraph PUB["Public Subnets"]
direction TB
subgraph P1["AZ-a Public Subnet"]
direction TB
ALB_A["ALB Node (AZ-a)"]:::edge
NAT_A["NAT GW (AZ-a)"]:::network
Bastion_A["Bastion (AZ-a)"]:::compute
end
subgraph P2["AZ-b Public Subnet"]
direction TB
ALB_B["ALB Node (AZ-b)"]:::edge
NAT_B["NAT GW (AZ-b)"]:::network
end
IGW2["IGW"]:::network
end

subgraph WEBPRIV["Private Web Subnets"]
direction TB
subgraph W1["AZ-a Private Web Subnet"]
direction TB
WEB_A["WordPress EC2 (ASG)"]:::compute
end
subgraph W2["AZ-b Private Web Subnet"]
direction TB
WEB_B["WordPress EC2 (ASG)"]:::compute
end
end

subgraph DATAPRIV["Private Data Subnets"]
direction TB
subgraph D1["AZ-a Private Data Subnet"]
direction TB
EFS_MT_A["EFS Mount Target (AZ-a)"]:::data
CACHE_A["Memcached Node (optional)"]:::data
end
subgraph D2["AZ-b Private Data Subnet"]
direction TB
EFS_MT_B["EFS Mount Target (AZ-b)"]:::data
CACHE_B["Memcached Node (optional)"]:::data
end
RDSCL["Aurora Cluster\n(Multi-AZ)"]:::data
end

subgraph SGBOX["Security Groups (02 SecurityGroups)"]
direction TB
SG_ALB["ALB SG\n(inbound 80/443)"]:::security
SG_WEB["Web SG\n(inbound from ALB SG, SSH from Bastion)"]:::security
SG_DATA["Data SGs\n(DB/EFS/Cache from Web SG)"]:::security
end

end

ALB_A -->|"routes_to"| WEB_A
ALB_B -->|"routes_to"| WEB_B
WEB_A -->|"egress"| NAT_A -->|"to"| IGW2
WEB_B -->|"egress"| NAT_B -->|"to"| IGW2

WEB_A <-->|"NFS:2049"| EFS_MT_A
WEB_B <-->|"NFS:2049"| EFS_MT_B
WEB_A <-->|"MySQL:3306"| RDSCL
WEB_B <-->|"MySQL:3306"| RDSCL
WEB_A <-->|"11211 (optional)"| CACHE_A
WEB_B <-->|"11211 (optional)"| CACHE_B

Bastion_A -->|"SSH:22"| WEB_A
Bastion_A -->|"SSH:22"| WEB_B

SG_ALB -.->|"allows"| ALB_A
SG_ALB -.->|"allows"| ALB_B
SG_WEB -.->|"protects"| WEB_A
SG_WEB -.->|"protects"| WEB_B
SG_DATA -.->|"protects"| RDSCL
SG_DATA -.->|"protects"| EFS_MT_A
SG_DATA -.->|"protects"| EFS_MT_B
SG_DATA -.->|"protects"| CACHE_A
SG_DATA -.->|"protects"| CACHE_B
end

%% =========================
%% Repo lifecycle/supporting artifacts (small vertical lane)
%% =========================
subgraph D["Repo Artifacts (samples/bits/CI)"]
direction TB
SAMPVPC["Sample Master (Existing VPC)"]:::iac
PARAMS["Sample Parameters (new VPC)"]:::iac
CLISH["Sample CLI Launch Script (new VPC)"]:::iac
INI["Sample INI Config"]:::compute
BITOP["Instance Artifact: OPcache status page"]:::compute
BITMC["Instance Artifact: ElastiCache client bundle"]:::compute
CI["CI Workflow (automation)"]:::observability

SAMPVPC -.->|"example_launch"| MS
PARAMS -.->|"inputs"| MS
CLISH -.->|"invokes"| MS
INI -.->|"runtime_settings"| WEB
BITOP -.->|"deployed_to"| WEB
BITMC -.->|"used_for"| WEB
CI -.->|"validates/publishes"| MS
end

%% =========================
%% Click Events (from component_mapping)
%% =========================
click MS "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-master-newvpc.yaml"
click SAMPVPC "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/samples/aws-refarch-wordpress-master-existing-vpc.yaml"
click N1 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-01-newvpc.yaml"
click S2 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-02-securitygroups.yaml"
click B3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-bastion.yaml"
click EFS3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-efsfilesystem.yaml"
click EFSAL3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-efsalarms.yaml"
click RDS3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-rds.yaml"
click EC3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-elasticache.yaml"
click ALB3 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-03-publicalb.yaml"
click WEB4 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-04-web.yaml"
click CF4 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-04-cloudfront.yaml"
click R53_5 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-05-route53.yaml"
click CW6 "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/templates/aws-refarch-wordpress-06-dashboard.yaml"
click BITOP "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/bits/opcache-instance-id.php"
click BITMC "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/bits/AmazonElastiCacheClusterClient-2.0.1-PHP70-64bit.tar.gz"
click PARAMS "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/samples/aws-refarch-wordpress-parameters-newvpc.json"
click CLISH "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/samples/aws-refarch-wordpress-sample-cli-newvpc.sh"
click INI "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/samples/20-aws.ini"
click CI "https://github.com/aws-samples/aws-refarch-wordpress/blob/master/.github/workflows/terraform.yml"

%% =========================
%% Styles
%% =========================
classDef edge fill:#1e88e5,stroke:#0d47a1,stroke-width:1.5px,color:#ffffff;
classDef compute fill:#2e7d32,stroke:#1b5e20,stroke-width:1.5px,color:#ffffff;
classDef data fill:#fb8c00,stroke:#e65100,stroke-width:1.5px,color:#111111;
classDef network fill:#90a4ae,stroke:#37474f,stroke-width:1.5px,color:#111111;
classDef observability fill:#6a1b9a,stroke:#4a148c,stroke-width:1.5px,color:#ffffff;
classDef security fill:#c62828,stroke:#7f0000,stroke-width:1.5px,color:#ffffff;
classDef iac fill:#546e7a,stroke:#263238,stroke-width:2px,color:#ffffff;
classDef external fill:#ffffff,stroke:#424242,stroke-width:1.5px,color:#111111,stroke-dasharray: 4 3;
```
