shiichan

Hyperdrive Can Now Reach Your Private Databases!

Hey there, it's Shiichan! Today I found an update that database folks will love.

Cloudflare Changelog developers.cloudflare.com

What was announced?

Hyperdrive can now connect to a private database through a Workers VPC service. This news comes from the Cloudflare Changelog.

A private database is one that lives inside your own network and is not exposed to the public Internet. With this update, you can now point Hyperdrive at those databases too.

The story so far

Until now, connecting Hyperdrive to a database meant that database had to be reachable from the public Internet. But production databases are often kept fully private for security reasons.

Cloudflare says going through a Workers VPC service is the recommended way to connect Hyperdrive to a private database.

What changes

Even a database that is not exposed to the Internet can now benefit from Hyperdrive's fast connection pooling and caching. You get to keep your DB private while still using it from Workers, which is great for security.

And Workers VPC services are reusable across Hyperdrive configurations, and can also be bound directly to Workers, so you can share the same private connection across multiple products.

Dive Deep

There are two ways to set it up.

One is the Cloudflare dashboard. When you create a Hyperdrive configuration, choose Connect to private database, then Workers VPC. You can pick an existing VPC service, or create a new one inline by choosing a Cloudflare Tunnel and entering your origin host and TCP port.

The other is the command line. Using wrangler, you can create a Hyperdrive configuration backed by a Workers VPC service with service ID, database name, user, password, and PostgreSQL scheme parameters.

For the full walkthrough, check the guide on connecting Hyperdrive to a private database using Workers VPC.

Wrap-up

  • Hyperdrive can now connect to private databases through Workers VPC
  • You can use a DB that is not exposed to the Internet, safely from Workers
  • You can set it up in the dashboard or with wrangler
  • Workers VPC services are reusable and can be bound directly to Workers

If you want to keep your production DB private but still crave Hyperdrive's speed, this update is for you!