DEV Community

Bulent Kocaman for PD Modules

Posted on

Selling managed AWS databases from WHMCS: five engines, one product line

Sooner or later a hosting customer asks for "just a database". Their app has outgrown the MySQL instance on their shared plan, or a developer wants PostgreSQL without running a server, or an accountancy package insists on SQL Server. Running those databases yourself means patching, backups and 3 a.m. pages. Pointing the customer at AWS means losing them.

The middle path is to sell managed databases from your own AWS account as ordinary WHMCS products. AWS runs the engine, patches it and takes the backups. You own the customer, the invoice and the margin. This post covers how to build that in WHMCS for all five relational engines, and the AWS charges that quietly outlive a cancelled service.

Which engine, on which AWS service

Engine AWS service Licence Points to know
MySQL Amazon RDS or Lightsail Open source Lightsail gives a flat monthly AWS cost for entry plans
PostgreSQL Amazon RDS or Lightsail Open source Same two-tier choice as MySQL
MariaDB Amazon RDS only Open source Lightsail doesn't offer MariaDB
Oracle Amazon RDS only Licence included (Standard Edition 2) Slow to create; heavier AWS cost
SQL Server Amazon RDS only Licence included (Standard Edition) No database is created for you

Two rows deserve a second look.

Oracle and SQL Server are licence-included. On RDS, AWS holds the Oracle licence for Standard Edition 2 and builds it into the hourly rate, and the same model applies to SQL Server Standard Edition. Neither you nor the customer buys a licence. That convenience is why these two cost noticeably more to run than the open-source engines, so give them their own product group and their own pricing rather than an add-on to a MySQL plan.

SQL Server creates no named database. An RDS SQL Server instance comes up with a master login and nothing else. The customer connects and runs CREATE DATABASE myapp; themselves. That's normal SQL Server behaviour, but if your welcome email promises "your database is ready" with a database name, expect a ticket. Say it on the product page and in the welcome email.

Lightsail or RDS for MySQL and PostgreSQL

Lightsail databases come as bundles with a fixed amount of memory, storage and data transfer, and a predictable monthly AWS cost. They suit entry plans: a WordPress site, a small app, a staging copy.

RDS is billed by the hour for the instance class plus the storage you allocate, and it's more flexible: larger instances, in-place resizing and a firewall per database. Use it for anything a customer will grow into.

The catch is that the two aren't interchangeable. Moving a live database from Lightsail to RDS, or between Lightsail bundles, means creating a new database and migrating the data. Decide the backing per product before you sell it, not after.

The AWS side

Create a dedicated IAM user for your database products, with API access only and no console login. AmazonRDSFullAccess covers creating, resizing, snapshotting and deleting RDS instances and reading their CloudWatch metrics. It doesn't cover two things people miss:

  • Security groups. If each database gets its own firewall (it should), the user also needs ec2:CreateSecurityGroup, AuthorizeSecurityGroupIngress, RevokeSecurityGroupIngress, DeleteSecurityGroup and the matching describe calls.
  • Lightsail. Lightsail databases are a separate service with separate permissions. Add them only if you sell Lightsail-backed plans.

Pick a region close to most of your customers, and remember that instance classes and engine versions vary by region. Build your order options from what AWS actually offers there, not from a list you typed once.

Building the product in WHMCS

Product type: Other. A database isn't a hosting account. The Shared Hosting and Server/VPS types add domain, hostname and root-password fields to the order form that a database has no use for.

Server record. Put the IAM access key in a server record, where WHMCS stores it encrypted, and assign the product to it.

Automatic setup. On the product's Module Settings tab, set Automatically setup the product to When the first payment is received. If you leave it off, the order completes, the service shows as Active and nothing is ever created at AWS.

Configurable options. Offer plan size, and for RDS storage, as configurable options so customers choose at checkout and pay your price for each. Upgrade/Downgrade then becomes the resize path: a bigger class or more storage. Note that RDS storage only grows; AWS can't shrink allocated storage, so don't offer a storage downgrade you can't deliver.

Cron. Database creation takes minutes, and Oracle can take a good deal longer. Provisioning, resizes and power actions finish in the background, so keep the WHMCS cron running frequently.

What the customer needs in the client area

At minimum:

  • connection details (host, port, database name where there is one, username, a password they can reset) and a link to the Amazon certificate bundle so they connect over TLS;
  • an IP allow-list firewall: no address can connect until they add one;
  • start, stop and reboot;
  • snapshots they can take and delete, plus a view of the automated daily backups;
  • CPU, connection, memory and free-storage graphs, so they can see when it's time to upgrade.

Where the AWS bill hides

A stopped RDS database still bills. Stopping saves instance hours, but AWS keeps charging for allocated storage, backup storage and any public IPv4 address. And after seven days stopped, AWS starts the instance again by itself so it can apply maintenance. A database you stopped for an unpaid invoice is running again a week later, with nobody paying for it.

A stopped Lightsail database bills in full. AWS says Lightsail databases accrue charges until they're deleted, stopped or not.

Snapshots bill while they exist. Manual snapshots stay until someone deletes them, including after the database itself is deleted. Let customers take snapshots, but make sure termination clears them.

High availability doubles the footprint. Lightsail's high-availability plans cost twice the standard plan because they run a second database and disk in another Availability Zone. RDS Multi-AZ is billed at its own Multi-AZ rate. If you offer either, sell it as its own tier.

Suspension and termination

Suspend by stopping the database: the data stays, the customer can't use it. Because AWS restarts stopped RDS instances after a week, something has to keep checking and stop it again, or a long-overdue account quietly costs you money. Services that stay unpaid should be terminated.

Termination should delete the instance, its security group and its snapshots, so the service leaves nothing behind. AWS lets you take a final snapshot on deletion; decide whether you want one, because if you keep it, you pay for it.

The module we built for this

We make one WHMCS module per engine. Each creates the customer's database on your own AWS account when WHMCS provisions the order: MySQL and PostgreSQL on a flat-priced Lightsail tier or on RDS, and MariaDB, Oracle Standard Edition 2 and SQL Server Standard Edition on RDS, the last two licence-included. Generate plans builds the configurable options for a product, and the client area gives the customer connection details, start/stop/reboot and password reset, snapshots and automated daily backups kept for seven days, an IP allow-list firewall on RDS plans, usage graphs and an activity log. Upgrading resizes an RDS database in place and keeps the data.

Suspending a service stops the database and keeps it stopped, even after AWS restarts it a week later. A suspend or unsuspend that arrives while the database is busy, mid-backup for example, is queued and applied as soon as AWS allows it. Terminating deletes the database with its automated backups, its snapshots and its firewall group. Every module installs and updates from the free PD Modules panel inside WHMCS, and an update that fails rolls itself back.

Module pages: PD AWS MySQL, PD AWS MariaDB, PD AWS PostgreSQL, PD AWS Oracle and PD AWS SQL Server.

This post is part of a series on reselling AWS from WHMCS; start with the overview.

Questions about selling databases from WHMCS are welcome in the comments.

PD Modules is made by Projektif Digital Ltd, the team behind PD Hosting.

Top comments (0)