Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evanshortiss/neon-pg-anon-example

Demonstrates how to use PostgreSQL Anonymizer with Neon's Postgres
https://github.com/evanshortiss/neon-pg-anon-example

Last synced: 21 days ago
JSON representation

Demonstrates how to use PostgreSQL Anonymizer with Neon's Postgres

Awesome Lists containing this project

README

        

# Neon's Serverless Postgres with PostgreSQL Anonymizer

A live demo of this application with "production" data is available at [the production URL](https://neon-pg-anon-example-xi.vercel.app/).

A preview environment with anonymized (masked) data can be viewed by visiting
a link added by GitHub Actions in Pull Request comments, e.g. [this PR comment](https://github.com/evanshortiss/neon-pg-anon-example/pull/2).

## Usage

If you'd like to use this example yourself, you'll need to:

1. [Sign-up for Neon](https://neon.tech/github) to access your free Postgres database.
1. Fork this repository and set some secrets for GitHub Actions.
1. Create a project in your Vercel account that uses your fork of this repository.

These steps are explained in detail provided below.

### Postgres Database Setup on Neon

1. Login and create a project on [Neon](https://neon.tech/github) to obtain a Postgres database.
1. Follow the instructions in Neon's documentation to [import the Employees database](https://neon.tech/docs/import/import-sample-data#employees-database).
1. Create a Neon database branch named `anonymized-main`, then run the commands in *anonymized.sql* against that branch.

### GitHub Action Setup

1. Fork this repository to your own GitHub account.
1. Create the following secrets in your forks repository settings for GitHub Actions:
* `NEON_API_KEY` - Found in the [account settings screen](https://console.neon.tech/app/settings/api-keys) in the Neon Console.
* `NEON_PROJECT_ID` - Can be found in the **Project settings** screen in the Neon Console.
* `VERCEL_TOKEN` - Create a token on the [Vercel Accounts Settings](https://vercel.com/account/tokens) screen.

### Vercel Setup

1. Create a Vercel project by importing your forked version of this repository into your Vercel account.
1. Go to *Settings > Environment Variables* in your Vercel project and create a `DATABASE_URL` variable that points to your employees database on Neon, e.g, `postgresql://username:[email protected]/employees?sslmode=require`. Make sure that this variable is set to apply only in the Production environment.
1. In your Vercel project, go to *Settings > Git > Ignored Build Step* and set it to `Don't build anything`. The reason for this is that you'll use GitHub
Actions to trigger the build.

That's it. Now, each pull request you open against your fork of this repository will use GitHub Actions to create a preview database branch containing anonymized data and deploy a Vercel preview environment that uses that anonymized preview branch.