Skip to content

AWS Hosting

Jerad Berhow edited this page Oct 12, 2026 · 2 revisions

AWS Hosting

Running PariahBot on Amazon Web Services, on one small EC2 virtual machine. Both install methods work on it: the container (Container Installation) or systemd (Host Installation). This page sets up the machine; the install itself is the same as anywhere else.

Complete Bot Setup first, because you'll need the token and application ID.

Why EC2, and not ECS, Fargate, App Runner or Lambda

  • The database needs a local disk. It's one SQLite file in WAL mode. ECS and Fargate tasks can only keep files across restarts on EFS, a network filesystem, and SQLite's WAL mode doesn't work on network filesystems. Tasks can corrupt it or lock each other out.
  • Exactly one copy may run. Two copies logged in with one token both answer every command and both run moderation, alerts and pollers. Services built to scale out, or that start the new task before stopping the old one during a deployment, make that easy to get wrong.
  • Nothing connects in. The bot holds one long-lived connection out to Discord. It doesn't serve web requests, so App Runner and Lambda don't fit, and Lambda can't hold the connection at all.
  • One small instance is the cheapest option anyway.

1. Launch the instance

In the EC2 console, choose Launch instance:

Setting Value
Name pariahbot
Application and OS Images Ubuntu, then Ubuntu Server 24.04 LTS. Not Amazon Linux: both setup scripts use apt-get. Choose the 64-bit (Arm) architecture for Graviton instance types, or 64-bit (x86) for the others
Instance type A small burstable type, e.g. t4g.small (Arm) or t3.small (x86), with 2 GiB of memory. 1 GiB types (t4g.micro, t3.micro) run the bot, with less headroom
Key pair Create one (RSA or ED25519, .pem) and download it, or choose one you already have
Network settings Tick Allow SSH traffic from and choose My IP. Leave Allow HTTPS and Allow HTTP unticked
Configure storage 20 GiB, gp3

Then Launch instance.

Don't open any other ports, including the dashboard's. The bot only connects out, and the dashboard listens on the instance's own 127.0.0.1, so it's reached through an SSH or Cloudflare Tunnel (step 4).

The instance gets a public IPv4 address, shown on its Details tab. It can change when the instance is stopped and started. That only affects how you SSH in, since nothing else connects to it. Attach an Elastic IP if you want it fixed.

2. Connect

From your computer, in the folder with the key:

chmod 400 pariahbot.pem          # macOS and Linux; PowerShell doesn't need it
ssh -i pariahbot.pem ubuntu@<public-ip>

The user name on Ubuntu images is ubuntu. You can also use Connect → EC2 Instance Connect in the console, which opens a terminal in your browser.

Bring the system up to date first:

sudo apt-get update && sudo apt-get upgrade -y
sudo reboot        # if it says a restart is required; then reconnect

3. Install the bot

git clone https://github.com/CosmicCubicle/PariahBot.git
cd PariahBot

Then one of:

sudo ./deploy/container-setup.sh     # container: see Container Installation
sudo ./deploy/setup.sh               # systemd: see Host Installation

Run it as ubuntu with sudo, not from a root shell. With systemd, ubuntu becomes the account the bot runs under. Answer the questions as the install page describes, then invite the bot (Bot-Setup) if you haven't yet.

To keep the bot on the newest code in main without logging in, answer yes when the script offers its update job. The systemd one is a cron job that syncs with main (see Host Installation → Auto-update job); the container one pulls new images of main. You can turn either on later by rerunning the script.

Both installs start again on their own when the instance reboots.

4. The admin dashboard (optional)

If you turned it on, the setup script printed the redirect URL to register. Reach the dashboard with an SSH tunnel from your computer:

ssh -i pariahbot.pem -L 8080:localhost:8080 ubuntu@<public-ip>

and open http://localhost:8080. Use your own port if it isn't 8080. For a public https:// address instead, use a Cloudflare Tunnel: see Admin-Dashboard → Making it public. Neither needs a security group change.

5. Backups

Snapshots of the instance's disk are the simplest. In the EC2 console, open Elastic Block Store → Lifecycle Manager and create a snapshot policy:

  • target the instance's volume, by a tag you add to it, e.g. Backup=pariahbot
  • schedule it daily
  • keep, say, 7 snapshots

A snapshot taken while the bot runs is like a sudden power cut, and SQLite is built to come back from one. For a copy that's exact to the moment, use the stop-and-copy steps on the install page you used; both have a Data and backups section.

Keep a copy of hom.env somewhere safe too, such as a password manager, so a lost key pair or instance doesn't lose the credentials.

Costs

The instance, its disk and its public IPv4 address are billed while the instance exists; a stopped instance still pays for its disk and any Elastic IP. Check current prices for your region with the AWS Pricing Calculator, and set a budget alert under Billing and Cost Management → Budgets.

Keeping it patched

Ubuntu installs security updates on its own (unattended-upgrades). Log in now and then to run sudo apt-get upgrade and reboot when it asks. The bot starts again by itself. Bot updates come from the install's own update job; see the install page.

Clone this wiki locally