# Hosting a fully Serverless Web-Based Postgres Admin Client on GCP using Pgweb, Cloud Run, & IAP

DevFeed: [Hosting a fully Serverless Web-Based Postgres Admin Client on GCP using Pgweb, Cloud Run, & IAP](<https://devfeed.tech/articles/hosting-a-fully-serverless-web-based-postgres-admin-client-on-gcp-using-pgweb-cloud-run-iap-23878.md>)

Original publisher: [Read original article](<https://engineering.premise.com/hosting-a-fully-serverless-web-based-postgres-admin-client-on-gcp-using-pgweb-cloud-run-iap-cff0ce8f471b?source=rss----c5fada0a103d---4>)

Author: Austen Novis

Published: 2023-03-06T13:17:20Z

Content type: tutorial

Language: en

Sources: [Engineering at Premise - Medium](<https://devfeed.tech/sources/engineering-at-premise-medium.md>)

Topics: [Cloud Run](<https://devfeed.tech/topics/cloud-run.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Google Cloud Platform (GCP)](<https://devfeed.tech/topics/google-cloud.md>), [Serverless](<https://devfeed.tech/topics/serverless.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [container](<https://devfeed.tech/topics/container.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [cli](<https://devfeed.tech/tags/cli.md>), [cloud-computing](<https://devfeed.tech/tags/cloud-computing.md>), [cloud-run](<https://devfeed.tech/tags/cloud-run.md>), [cloud-sql](<https://devfeed.tech/tags/cloud-sql.md>), [cloudrun](<https://devfeed.tech/tags/cloudrun.md>), [container](<https://devfeed.tech/tags/container.md>), [deploy](<https://devfeed.tech/tags/deploy.md>), [gcp](<https://devfeed.tech/tags/gcp.md>), [google-cloud-platform](<https://devfeed.tech/tags/google-cloud-platform.md>), [identity-aware-proxy](<https://devfeed.tech/tags/identity-aware-proxy.md>), [pgweb](<https://devfeed.tech/tags/pgweb.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [vpc](<https://devfeed.tech/tags/vpc.md>)

## AI overview

A tutorial explains how to deploy Pgweb, a Go-based PostgreSQL administration client, as a serverless web application on Google Cloud. It uses Cloud Run, CloudSQL, a CloudSQL connector, Secret Manager, Artifact Registry, and optionally an HTTP load balancer with Identity-Aware Proxy for authentication.

## Source excerpt

By Austen Novis, Staff Software Engineer Pgweb example screenshot There are a number of quality Postgres open source administration tools such as pgAdmin or DBeaver, but these tools require a persistent server to run. This means that each user needs to install the tool locally and setup their connections, or you need to host the tool in a cloud server, which can get expensive. A much cheaper alternative is to use Pgweb, a lightweight web-based database explorer for PostgreSQL written in Go, and deploy to Cloud Run. This allows you to utilize a web-based tool, for minimal cost, that can scale for any number of users. We will leverage several Google Cloud Platform services for the complete setup starting with a http load balancer to allow for a custom DNS name as well as enable Identity Aware Proxy (IAP), which is what we will be using for authentication. We will host the service in Cloud Run and connect directly to CloudSQL using a CloudSQL connector. You can bypass the load balancer and IAP if you would like to use username and passwords for authentication. Cloud componentsCloud Setup The first step is setting up your CloudSQL instance. This can be done via terraform or in the GCP console. The main requirement is that you enable a public ip address, which will allow us to use the CloudSQL Auth proxy to connect our Cloud Run instance to our CloudSQL instance. If this is not possible you can still connect to your CloudSQL instance to Cloud Run through a VPC Connector instead. Next we will need to save our database connection credentials in GCP's Secret Manger by creating a new secret called PGWEB_DATABASE_URL in the format of postgres:///DB_NAME?host=/cloudsql/PROJECT:REGION:INSTANCE_NAME&user=DB_USER&password=DB_PASSWORD . Now that we have our CloudSQL instance and connection secret we will deploy our Cloud Run instance using the gcloud cli. First we will need to push the desired Pgweb container to GCP's Artifact Registry, which we can do using the following commands