shotparty

a self-hosted qr-code photo and video drop for events, serverless on aws

source site

shotparty is a self-hosted photo and video drop for events. Guests scan a QR code, pick photos and videos on their phone, and the files land at full quality in an S3 bucket in your own AWS account. There’s no app, no guest account and no subscription. It’s serverless: CloudFront in front of a static page and a small API on API Gateway and Lambda, with a DynamoDB table, all defined in AWS SAM and deployed with one command. This blog post covers how it was built.

The project site gives the short tour. The GitHub repo has the quick start, the operations guide and a detailed ā€œhow it worksā€ walkthrough of every subsystem.

Tech Stack

Layer Technology
Guest page Vite + TypeScript, no runtime dependencies, mobile-first, light and dark
Hosting CloudFront on the Free flat-rate plan (CDN, WAF, TLS), private S3 site bucket with OAC
API API Gateway HTTP API, 5 Lambdas (Node 22, arm64, bundled with esbuild)
Uploads S3 presigned POST, straight from the browser to the media bucket
Validation EventBridge Object Created → a Lambda that checks magic bytes
Data DynamoDB single table (on-demand, TTL, PITR)
Secrets SSM Parameter Store SecureStrings
Bot check Cloudflare Turnstile, verified server-side
Monitoring CloudWatch alarms and log metric filters, SNS email, AWS Budgets
Infrastructure AWS SAM (CloudFormation), three stacks
Tooling TypeScript CLI scripts and bash, npm run setup
Tests and CI Vitest (445 unit tests), Playwright (12 end-to-end tests), GitHub Actions, CodeQL, Dependabot

Architecture

Components

shotparty architecture A guest's phone reaches CloudFront, on the Free plan with its WAF and TLS. CloudFront serves the upload page from a private S3 site bucket and sends /api/* to an API Gateway HTTP API. The HTTP API invokes the event, session and presign Lambdas, which use a DynamoDB table and SSM parameters, and the session Lambda verifies the guest with Cloudflare Turnstile. The presign Lambda returns a presigned POST, and the phone uploads the file straight to the S3 media bucket. The bucket sends an Object Created event through EventBridge to the validate Lambda, which copies real media to accepted/ or deletes the upload. Guest’s phone browser, no app CloudFront Free plan: WAF + TLS CF Function on /api/* Site bucket S3 Ā· OAC Ā· upload page HTTP API /api/* Ā· 50 rps Lambdas event Ā· session Ā· presign reserved concurrency DynamoDB events Ā· sessions Ā· quotas SSM Parameter Store secrets Ā· kill switch siteverify Cloudflare Turnstile bot check presigned POST S3 media bucket uploads/ → accepted/ data stack EventBridge Object Created validate Lambda magic bytes Ā· duplicates copy or delete Per stage: a data stack (media bucket, table) and an app stack (everything else), plus one account budget stack. All in us-east-1.

Upload sequence

Upload sequence The page fetches the event from the API through CloudFront and API Gateway and gets its name, status and Turnstile site key. It then posts a Turnstile token, plus a PIN if needed, to /api/session. The session Lambda verifies the token with Cloudflare, runs the gate checks, stores the session in DynamoDB and returns a signed 12-hour session. For each file, the page posts to /api/presign with the session. The presign Lambda makes three conditional quota updates in DynamoDB and returns a presigned POST for the exact key, type and size, valid for 10 minutes. The page posts the file straight to S3, which returns 204. S3 then sends an Object Created event through EventBridge to the validate Lambda, which reads the first 64 bytes and either copies the file to accepted/ or deletes it. Browser API Lambdas Turnstile DynamoDB S3 media validate GET /api/event/{token} via CloudFront + API Gateway name, status, site key POST /api/session Turnstile token (+ PIN) siteverify success gate checks Ā· PutItem SESSION signed 12 h session for each file POST /api/presign Bearer session 3 conditional quota updates presigned POST exact key, type, size Ā· 10 min POST file, straight to S3 204 Object Created via EventBridge read 64 bytes copy to accepted/ or delete
Requests that go straight to the API Gateway URL, skipping CloudFront, get a 403. The validator also claims each file's MD5 in DynamoDB, so the same photo from the same guest is stored once.

Abuse protection

The page is public and writes to your bucket, so it’s protected in layers. The goal is to make scripted abuse impractical and to put a hard ceiling on the worst case.

# Layer What it stops
1 WAF (3,000 requests / 5 min per IP plus AWS managed rules), API throttling, reserved Lambda concurrency Floods. Also caps the API and Lambda bill
2 128-bit event token in the QR URL, plus an optional PIN printed on the card Scanners and crawlers that never saw the card
3 Cloudflare Turnstile, verified server-side before a session is issued Headless scripts and simple bots
4 Signed 12-hour session, required on every presign Reusing one human check across many bots
5 Quotas: 500 files / 10 GiB per session, 3,000 files/hour per IP, 20,000 files / 100 GiB per event One guest or bot filling the bucket
6 Presigned POST policy: server-chosen key, exact type and byte size, 10-minute expiry Oversized files, overwrites, arbitrary paths
7 Magic-byte validation after upload Junk, executables and archives renamed as photos
8 Upload window and an SSM kill switch, checked on every request Uploads after the event. Gives an instant off switch
9 CloudWatch alarms emailing through SNS, and an account budget Surprises of any kind

Worst case: S3 doesn’t charge for incoming data, so filling an event’s 100 GiB cap with junk costs about $2.30/month until it’s deleted.

Supported files

JPEG, PNG, HEIC/HEIF, WebP, GIF, MP4, MOV, WebM and 3GP, plus camera RAW: DNG (including iPhone ProRAW), CR2, CR3, NEF, ARW, RAF, ORF and RW2. The default limit is 1 GiB per file, and the config can raise it to 5 GiB.

Deployment

Stacks

Stack Contains Protection
<prefix>-<stage>-data Media bucket, DynamoDB table Termination protection, a stack policy denying replace and delete, Retain policies, S3 versioning, DynamoDB deletion protection and PITR
<prefix>-<stage>-app Lambdas, HTTP API, CloudFront, site bucket, alarms None needed. Safe to delete and recreate without losing data
<prefix>-account The account budget, shared by the stages None needed

The data stack publishes its resource names to SSM, and the app stack reads them from there. CloudFormation exports aren’t used, because they lock both stacks against edits. Every deploy creates a change set first, and a guard refuses any change that would replace or remove the bucket or table, or replace the CloudFront distribution the printed QR codes point at.

Setup

  1. Log in: aws sso login (or any AWS CLI credentials), and export a Cloudflare API token for prod.
  2. Run setup: npm run setup asks a few questions and saves shotparty.config.json. It then creates the secrets, deploys the data and app stacks, creates the Turnstile widget through Cloudflare’s API, creates the first event with its QR code, and runs a health check. Re-running it resumes after a failure and changes nothing on a finished install.
  3. By hand: confirm the alert email, print the QR code, and optionally subscribe the distribution to the CloudFront Free plan in the console (there’s no API for it), then run setup again to attach its WAF.

After the event

  1. npm run download pulls every accepted file and verifies each one’s MD5 against S3.
  2. The upload window closes on its own, or scripts/uploads.sh prod off closes it early.
  3. Optionally, archive to Glacier Instant Retrieval, or tear down the app stack and keep the data.

Estimated Cost

For a typical event of ~100–200 guests and 15–25 GB.

Item Estimate
CloudFront Free plan (CDN, WAF, TLS, 5 GB S3 credit) $0
S3 Standard, ~25 GB ~$0.46 / month
S3 requests < $0.05
API Gateway, Lambda, DynamoDB on-demand pennies
Uploads in, and downloading everything once $0
CloudWatch alarms ~$0.30 for one stage, ~$1.60 for dev + prod
Cloudflare Turnstile $0
Total ~$1–$2 / month while live. About $0.10/month archived, or $0 after download and delete

Not used, on purpose: a custom domain, Secrets Manager, WAF CAPTCHA and Bot Control, and a standalone WAF web ACL.

Highlights

Known Limitations

How it got built: blog →