https://github.com/peter554/gcp-cloud-run-contacts
GCP Cloud Run example with Cloud SQL
https://github.com/peter554/gcp-cloud-run-contacts
gcp gcp-cloud-run gcp-cloud-sql golang
Last synced: 10 months ago
JSON representation
GCP Cloud Run example with Cloud SQL
- Host: GitHub
- URL: https://github.com/peter554/gcp-cloud-run-contacts
- Owner: Peter554
- Created: 2021-06-20T14:27:18.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-20T18:09:58.000Z (almost 5 years ago)
- Last Synced: 2024-10-19T11:28:46.563Z (over 1 year ago)
- Topics: gcp, gcp-cloud-run, gcp-cloud-sql, golang
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gcp-cloud-run-contacts
[](https://github.com/Peter554/gcp-cloud-run-contacts/actions/workflows/ci.yml)
An example app using GCP Cloud Run with Cloud SQL.
## Project ID
- Set the GitHub actions secret `GCP_PROJECT_ID`
## Database preparations
https://cloud.google.com/sql/docs/postgres/connect-run
- 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`).
- Set the GitHub actions secret `GCP_SQL_CONNECTION_NAME`.
- 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-cloudrun/)
- Set the GitHub actions secret `GCP_CREDENTIALS`.