Skip to main content

Supabase

Supabase platform gives us possibility to host Postgres instance on free tier, hence it could be one of the possible optimal solutions for Terraform state management.

danger

It is important to keep in mind that free tier Supabase organization keeps your project alive only if it was used within last 7 days! It means that your infrastructure state might be deleted if you don't perform any operations in that project.

Create Postgres instance​

First, if you don't have it already, you need to create Supabase account.

(optional) New organization​

If you don't have an Organization already or want to have this project under new Organization you need to navigate to your Projects dashboard and click Create organization button.

Visual instruction on how to create new organization in Supabase

Create new project for infrastructure​

Go to your Projects dashboard and click New project.

Image showing where to click to create new project in Supabase

Supabase will ask you about the project settings, you need to:

  • Pick a name for the project with -infra suffix, for example runtyme-infra
  • Generate Database password
tip

Save this password in a secure note, you'll need it later

  • Pick a region which suits your case best
  • Expand Security options tab and choose Only Connection String option (we only need Postgres instance)
  • Click Create new project button

Image explaining what to choose when creating new project in Supabase

Wait until Supabase creates your Project (can take up to 5 minutes), voila!

Important

Supabase access management is handled by RLS (Row Level Security) to secure your data within your Supabase instance. This configuration is manual, so make sure you check this guide and secure your database properly.

Configure GitHub actions​

To configure your GitHub Actions workflow in order to properly manage your infrastructure's state, you need to go to your Supabase's Projects dashboard and pick infrastructure project created in previous step.

Visual picking project in Supabase instruction

After that, go to Project Settings on the bottom of the side bar and click Database tab under Configuration section.

You need to find Database connection string URI, switch mode to Session and click Copy button.

Image instruction on how to find and copy database connection string URI in Supabase

When you copy database connection string URI, you can navigate to your GitHub repository, where you plan to use runtyme-kit.

In repository, go to Settings tab, under Security section, find Secrets and variables->Actions.
In Secrets tab, click New repository secret button.

How to create new secret for actions in GitHub

Secret must be named TF_BACKEND_PG_CONN_STR and the value should be the Database connection string URI you have copied.

Visual representation of adding connection string uri secret instruction and it's values

info

Make sure ...[YOUR-PASSWORD]... string is replaced with your database password defined when Supabase project was created in previous section