Connect a Web App with Aurora¶
| Category | Cloud & AWS Data & Serverless |
| Status | ๐ก Partially completed |
| Repo | nextwork-connect-a-web-app-with-aurora |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Connect a Web App with Aurora guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ Cloud & AWS Data & Serverless
Status: ๐ก Partially completed
Overview¶
A small PHP web app on EC2 (Apache) that saves form input to an Aurora MySQL database and lists it. Mine is a team directory: name and city, stored with PDO prepared statements and escaped when shown. Connection settings come from the environment, not a hard-coded file.
Summary¶
On 2 Dec 2026 I ran this on real AWS: EC2 as the Apache + PHP server, Aurora MySQL behind it, the form submitted, rows stored and shown, and an injection attempt stored as harmless text. Everything was torn down. On 3 Dec I replaced that page, which followed the guide's sample code, with my own (web/html/index.php) and checked it end to end against MySQL 8 in Docker (7 of 7 checks). The Terraform still passes on the local AWS mock. The new page hasn't been run on AWS, because that would mean spending again, so this is marked partial. The real-AWS log below is from the earlier page.
The checks behind this are in docs/verification.txt.
Skills & tools¶
AWS, Terraform, Infrastructure as Code, moto (AWS mock), PHP, Apache, MySQL, Amazon Aurora, Amazon EC2, Docker Compose, SQL injection prevention
What I built¶
web/html/index.php(my own): a team directory with apeopletable created on first use, PDO prepared statements, output escaping, input length checks, redirect after post, and database errors logged rather than shown.web/inc/dbinfo.inc: reads DB settings from the environment.docker-compose.ymlandweb/Dockerfile: php:8.3-apache with pdo_mysql, plus MySQL 8.web-e2e.sh: 7 checks covering add, redirect, an injection attempt, a refused empty field, the rendered list, the count, and the row count in MySQL itself.real-extra.sh: the on-instance deploy and test for AWS, updated for the new page (not rerun on AWS).main.tf: Aurora cluster, writer, EC2, and SGs (as in the previous project).
How to run¶
docker compose up --build -d && open http://localhost:8088/ # local app
./web-e2e.sh # automated test
pip install -r requirements-dev.txt && ./local-test.sh
Verification¶
I ran the verification command on 2026-12-03, after the rewrite. The full output is in docs/verification.txt.
PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH TF_PLUGIN_CACHE_DIR=/workspace/nextwork-portfolio/tf-plugin-cache ./local-test.sh && ./web-e2e.sh
Real AWS deployment (2026-12-02)¶
Note: this run and
docs/aws-real-run.txtused my earlier page (SamplePage.php, based on the guide's sample). The page has since been rewritten in my own code and tested locally only.
I deployed this project to a real, dedicated AWS learning account (us-east-1, kept separate from everything else I run), checked it, captured the output, and tore it all down right after. Every resource carried the tag Project=nextwork-connect-a-web-app-with-aurora so I could prove nothing was left behind.
How I ran it: ./real-aws-run.sh (in this repo) does terraform init/apply with my AWS profile, runs checks.py against the real account, runs real-extra.sh for the live tests, and then always runs terraform destroy, even if a step fails. To get onto the instances I used EC2 Instance Connect with a throwaway SSH key that is only valid for 60 seconds. No key pairs were created in AWS and no keys were saved. The page was requested on the instance itself (curl localhost), so no web port was opened to the internet. The database password was random for each run, piped over SSH stdin into dbinfo.inc (mode 640, group apache), and never printed or committed. My first attempt was interrupted mid-deploy, so I resumed it, tore it down and ran it again cleanly. Both are in the spend ledger.
Evidence (excerpt; the full, sanitized transcript is in docs/aws-real-run.txt, with the account ID redacted):
$ python3 checks.py (against the real account)
ALL 3 CHECKS PASSED
$ ./real-extra.sh
aurora-mysql 8.0.mysql_aurora.3.10.3 available
--- install Apache + PHP + mysqli on the instance
Server version: Apache/2.4.71 (Amazon Linux)
PHP 8.5.13 (cli) (built: Nov 17 2026 14:30:51) (NTS gcc x86_64)
--- deploy SamplePage.php and dbinfo.inc (DB_SERVER = Aurora writer endpoint; password sent over SSH stdin, not printed)
dbinfo.inc written
--- submit the form twice (one SQL-injection attempt) and read the page back
POST -> HTTP 200
POST -> HTTP 200
<h1>NextWork Employee Directory</h1>
<tr><td>1</td><td>Ada Lovelace</td><td>London</td></tr>
<tr><td>2</td><td>Robert'); DROP TABLE EMPLOYEES;--</td><td>Bobby Tables Lane</td></tr>
Teardown¶
Resources were up from 20:45 to 20:59 CST on 2026-12-02, then destroyed and verified gone:
=== TEARDOWN 2026-12-02 20:53 CST ===
$ terraform destroy -auto-approve -input=false -no-color -var ami_id=ami-000d209a4fc9822c4 -var project_tag=nextwork-connect-a-web-app-with-aurora
Destroy complete! Resources: 5 destroyed.
$ terraform state list (should be empty)
$ aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=nextwork-connect-a-web-app-with-aurora
$ live EC2 instances / volumes / VPCs tagged Project=nextwork-connect-a-web-app-with-aurora (should be empty)
=== teardown verified 20:59 CST ===
Cost¶
Estimated cost of the real run: about $0.03 for this run, plus about $0.03 for an earlier interrupted attempt (db.t3.medium Aurora writer plus a t2.micro, about 14 minutes each). The account has a $50/month budget with email alerts at $5, $20 and $40, and the whole AWS series is logged in a private spend ledger.
Original project: https://nextwork.ai/projects/921d7b78-ffa4-5e41-a5b5-aed76c78efad ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ PATH=/workspace/nextwork-portfolio/.venv/bin:$PATH TF_PLUGIN_CACHE_DIR=/workspace/nextwork-portfolio/tf-plugin-cache ./local-test.sh && ./web-e2e.sh
Success! The configuration is valid.
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
cluster_id = "nextwork-aurora"
db_sg = "sg-5278a5d87983121a5"
ec2_sg = "sg-1de58fc258c8bf1c3"
writer_endpoint = "nextwork-aurora.cluster-bgvbva5hch8x.us-east-1.rds.amazonaws.com"
PASS: Aurora MySQL cluster created
PASS: cluster has a writer instance
PASS: DB SG admits 3306 only from the EC2 SG
ALL 3 CHECKS PASSED
ok adding Grace Hopper answers 303 (redirect after post)
ok an injection attempt is accepted as an ordinary name
ok an empty city is refused with a message
ok Grace Hopper is listed
ok the injection text is shown escaped, not run
ok the page counts 2 people
ok MySQL itself holds exactly 2 rows
WEB E2E PASSED
[exit code 0]