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

https://github.com/peter554/gcp-app-engine-contacts

GCP App Engine example with Cloud SQL
https://github.com/peter554/gcp-app-engine-contacts

gcp gcp-appengine-std gcp-cloud-sql golang

Last synced: 12 months ago
JSON representation

GCP App Engine example with Cloud SQL

Awesome Lists containing this project

README

          

# gcp-app-engine-contacts

[![CI](https://github.com/Peter554/gcp-app-engine-contacts/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Peter554/gcp-app-engine-contacts/actions/workflows/ci.yml)

An example app using GCP App Engine with Cloud SQL.

## Database preparations

https://cloud.google.com/sql/docs/postgres/connect-app-engine-standard#go

- Create a Cloud SQL postgres instance.
- Connect to the instance (`gcloud sql connect`) and create the contacts table:

```sql
create table if not exists contacts (
id serial primary key,
name varchar(100),
email varchar(100)
);
```

- Obtain the `INSTANCE_CONNECTION_NAME` (`gcloud sql instances describe`).
- Determine the postgres Data Source Name (DSN): `user=postgres password= database=postgres host=/cloudsql/`
- Set the GitHub actions secret `GCP_SQL_DSN`.

## Service account

- Create a service account and obtain a JSON key (https://github.com/google-github-actions/deploy-appengine)
- Set the GitHub actions secret `GCP_CREDENTIALS`.