# Elastic Beanstalk — Running PDHPI on Managed AWS

Beanstalk takes a source bundle and runs it on EC2 behind an ALB. For
a single-file PHP app like PDHPI, it is the fastest path from code
to a live URL.

## Deploy

1. Zip `index.php`, `sim.php`, `report.php`, `docs/`, `assets/`, and `storage/`
2. Create a Beanstalk application, choose the PHP platform
3. Upload the zip
4. Beanstalk provisions EC2, ALB, TLS, and gives you a URL

To update: upload a new zip. Beanstalk performs a rolling deployment.

## State

Both engines read and write `storage/state.json`. On Beanstalk, each
EC2 instance has its own filesystem. Scaling beyond one instance causes
state to drift.

Three options:

- **Single instance** — auto-scaling group fixed at 1.
- **EFS** — mount a shared volume across all instances.
- **DynamoDB** — refactor `sim_load()` and `sim_save()`.

For a first engagement, start with single-instance and migrate to
DynamoDB if traffic demands it.