All posts

7 min read

Cloud developer learning Supabase: what carries over, what's new, 30-day plan

Practical guide for cloud engineers transitioning to Supabase, covering transferable skills, new concepts, pitfalls, a 30‑day roadmap, and quick FAQ.

What carries over

Cloud conceptSupabase equivalentWhy it still matters
Infrastructure as Code (IaC)supabase projects create via the Supabase CLI, plus Terraform provider for SupabaseYou already write Terraform modules or CloudFormation stacks; the same declarative mindset applies when provisioning databases, auth, and storage.
SQL‑first mindsetPostgreSQL instance managed by SupabaseSupabase runs on vanilla PostgreSQL, so all your knowledge of schemas, indexes, CTEs, and extensions (e.g., pgcrypto) transfers directly.
Environment variables & secret management.env file for SUPABASE_URL and SUPABASE_ANON_KEY, plus Supabase's built‑in secrets UIYou already inject secrets at deploy time; Supabase expects the same pattern, just with its own naming conventions.
Serverless functions / edge computeSupabase Edge Functions (Node.js runtime)The idea of stateless functions triggered by HTTP or auth events is identical; only the deployment command changes (supabase functions deploy).
ObservabilitySupabase logs (via the dashboard) and supabase db log CLIYour habit of tailing logs, setting alerts, and correlating request IDs continues, just with Supabase‑specific endpoints.
Role‑based access control (RBAC)PostgreSQL GRANT statements + Supabase Row Level Security (RLS) policiesYou already design least‑privilege roles; Supabase adds a declarative RLS layer that you configure with SQL.
CI/CD pipelinesUse the same GitHub Actions or GitLab CI, just add Supabase CLI steps (supabase db push, supabase functions deploy)The pipeline structure—checkout, test, deploy—remains unchanged.
API gateway patternsSupabase auto‑generates a RESTful endpoint (/rest/v1) and a GraphQL endpoint (/graphql/v1)If you’re used to API gateways (API Gateway, Azure API Management), you’ll recognize the same request‑routing concepts; Supabase just provides them out of the box.

What's new

Supabase abstracts a lot of the plumbing you normally provision yourself. Below are two common tasks—creating a table and securing it—with a pure‑cloud approach versus the Supabase approach.

Cloud (manual PostgreSQL + custom auth)

# 1. Create a PostgreSQL instance (e.g., using AWS RDS)
aws rds create-db-instance \
  --db-instance-identifier mydb \
  --engine postgres \
  --master-username admin \
  --master-user-password $DB_PASSWORD \
  --allocated-storage 20

# 2. Connect and create a table
psql "host=$HOST dbname=postgres user=admin password=$DB_PASSWORD" <<SQL
CREATE TABLE todos (
  id SERIAL PRIMARY KEY,
  user_id UUID NOT NULL,
  title TEXT NOT NULL,
  completed BOOLEAN DEFAULT FALSE,
  created_at TIMESTAMPTZ DEFAULT now()
);
SQL

# 3. Write a Lambda authorizer to enforce ownership
# (pseudo‑code, language agnostic)
function authorize(event) {
  const token = event.headers.Authorization;
  const user = verifyJwt(token, JWKS_URL);
  // Attach user ID to request context
  return { principalId: user.sub };
}

Supabase

# 1. Initialise a Supabase project (CLI)
supabase init
supabase start   # runs local Docker containers

# 2. Create the same table via migration
supabase db reset   # creates a fresh DB
cat <<SQL > supabase/migrations/20240101_create_todos.sql
create table todos (
  id bigint generated by default as identity primary key,
  user_id uuid not null,
  title text not null,
  completed boolean default false,
  created_at timestamptz default now()
);
SQL
supabase db push   # applies migration

# 3. Enable Row Level Security and a policy
supabase db remote set --project-ref <ref>
psql $SUPABASE_DB_URL <<SQL
alter table todos enable row level security;
create policy "owner can manage own todos"
  on todos for all
  using (auth.uid() = user_id);
SQL

What changed and why

AspectCloudSupabase
ProvisioningYou spin up a DB instance, configure networking, backups, etc.Supabase spins up a fully managed PostgreSQL cluster; the CLI abstracts the create-db-instance call.
Auth integrationYou must build or integrate an identity provider and pass the user ID to your services.Supabase Auth is baked in; auth.uid() is available in RLS policies, eliminating custom token verification.
API surfaceYou expose your own REST/GraphQL layer (e.g., via API Gateway + Lambda).Supabase auto‑generates /rest/v1 and /graphql/v1 endpoints that respect RLS automatically.
Deployment frictionMultiple scripts, IAM roles, and separate CI steps.Single CLI command (supabase db push) updates schema; functions are deployed with supabase functions deploy.

Common pitfalls

  1. Assuming Supabase is “serverless” for everything – Only Edge Functions run serverlessly; the PostgreSQL instance is a managed service, not a stateless function. Heavy batch jobs should still be offloaded to a proper compute service.
  2. Neglecting RLS – By default, tables are open to anyone with the service key. Forgetting to enable RLS and write policies exposes data. Always ALTER TABLE … ENABLE ROW LEVEL SECURITY early in the schema design.
  3. Mixing service role and anon key – The SUPABASE_SERVICE_ROLE_KEY bypasses RLS. Use it only in trusted back‑ends (e.g., CI jobs). Accidentally using it in a client‑side app grants full admin rights.
  4. Over‑relying on auto‑generated REST – The auto‑generated /rest/v1 endpoint follows PostgREST conventions. Complex queries (joins, aggregates) may require RPC functions or GraphQL; trying to force everything through the generic endpoint can lead to inefficient queries.
  5. Version drift between local and remote – supabase start runs a local Docker stack. If you manually modify the local DB without a migration, supabase db push will fail on remote. Keep every schema change in a migration file.
  6. Ignoring storage bucket CORS – Supabase Storage defaults to a restrictive CORS policy. If your front‑end can’t fetch images, you need to add the appropriate origins via the dashboard or supabase storage bucket update.

Your 30‑day plan

Week 1 – Foundations

  1. Install the Supabase CLI, Docker, and set up a local dev environment (supabase start).
  2. Create a new project on supabase.com, note SUPABASE_URL, SUPABASE_ANON_KEY, and SUPABASE_SERVICE_ROLE_KEY.
  3. Write your first migration: a users table with UUID primary key, email, created_at.
  4. Enable RLS on users and add a policy that only the owner can read/write their row.
  5. Mini‑project: Build a simple sign‑up / login flow using Supabase Auth (email‑magic link) and store a profile row linked to the user.

Week 2 – Data access patterns

  1. Add a posts table with a foreign key to users.
  2. Create an RLS policy that allows anyone to read posts but only the author to edit/delete.
  3. Experiment with the auto‑generated REST endpoint: GET /rest/v1/posts?select=*.
  4. Write a PostgREST RPC (create_post) that inserts a post and returns the inserted row.
  5. Mini‑project: Build a tiny “micro‑blog” front‑end that lists posts, lets the logged‑in user create a post, and updates in real time using Supabase Realtime.

Week 3 – Edge Functions & Storage

  1. Scaffold an Edge Function (supabase functions new send-welcome-email).
  2. Use the @supabase/supabase-js client inside the function to fetch the new user’s email and send a mock email (log to console).
  3. Deploy the function and hook it to the auth.sign_up webhook via the dashboard.
  4. Create a storage bucket avatars, configure public read CORS for your domain.
  5. Mini‑project: Extend the micro‑blog to allow users to upload an avatar image; display it next to each post.

Week 4 – CI/CD, Monitoring, and Production Prep

  1. Add Supabase CLI steps to your existing GitHub Actions workflow: supabase db push, supabase functions deploy.
  2. Enable Supabase logs streaming (supabase logs tail) and set up a simple alert (e.g., email on function error) using your cloud provider’s alerting service.
  3. Review all RLS policies, run supabase db reset --skip-seed on a fresh clone to verify migrations are reproducible.
  4. Harden secrets: move SUPABASE_ANON_KEY and SERVICE_ROLE_KEY to your provider’s secret store; ensure they are never committed.
  5. Capstone project: Deploy the micro‑blog to a production‑like environment (Vercel, Netlify, or static hosting) using the same CI pipeline; verify auth, storage, and edge function work end‑to‑end.

FAQ

How does Supabase Auth differ from Cognito or Azure AD?

Supabase Auth is a lightweight, email‑first system with built‑in JWTs; it lacks the extensive federation and SAML features of Cognito/Azure AD but integrates tightly with Postgres RLS via auth.uid().

Can I use my existing PostgreSQL instance with Supabase features?

Only the managed Supabase Postgres instance supports the built‑in RLS helpers and auto‑generated APIs. You can connect external tools, but you lose the seamless Auth‑RLS integration.

Are Edge Functions the same as AWS Lambda?

Conceptually yes—stateless functions triggered by HTTP or auth events—but they run on Deno (or Node) within Supabase’s infrastructure and are deployed with supabase functions deploy.

Do I still need a separate CDN for static assets?

Supabase Storage can serve public files directly, but for high‑traffic sites a CDN (e.g., Cloudflare) in front of the bucket can improve latency and caching.

Keep going

#supabase #cloud #onboarding #guide