Skip to content

Latest commit

 

History

History
61 lines (52 loc) · 2.38 KB

README.md

File metadata and controls

61 lines (52 loc) · 2.38 KB

Fabra

Introduction

To deploy this system in production, there are only a few manual steps:

  1. Setup a GCP Project
  2. Create Terraform Google Cloud Storage bucket
  3. Perform initial Terraform run

1. Setup GCP Project

Create a new GCP project and take note of the name and project ID.

2. Create Terraform GCP Cloud Storage bucket

This Google Cloud Bucket is used as a backing store for Terraform, so must be manually setup. Note the name you use as you'll need to edit infra/terraform/main.tf to point to it.

3. Initial Terraform run

Once those two things are setup, everything else can be configured with Infrastructure-as-code in Terraform. However, you must run terraform apply once manually to setup the correct permissions for the Cloud Build service account to run Terraform automatically in the future.

Deploy to new region

  1. Create a new GCP project.

  2. Create a new Terraform file for the region by copying infra/terraform/main.tf into a new subdirectory

    1. Modify the project ID in the new Terraform file
    2. Modify the Cloud Storage bucket names to match the new region:
      1. Terraform bucket
      2. Frontend bucket
      3. Connect bucket
    3. Run terraform init in the new subdirectory
  3. Enable all the GCP APIs needed:

    1. Cloud Build
    2. Cloud Engine
    3. Cloud Run
    4. Cloud SQL
    5. IAM
    6. KMS
    7. DNS
    8. Secret Manager
    9. Serverless VPC Access
    10. Service Networking
    11. Artifact Registry
    12. Kubernetes Engine
  4. Create a new DB password in the new projects Secret Manager with the name fabra-db-password

  5. Create a new Terraform bucket in Cloud Storage and add it to the Terraform file

  6. Connect the Github repository to the new GCP project

  7. Copy OAuth secrets to the new project's Secret Manager and ensure the code references them correctly

  8. Enable Cloud Build to deploy to Cloud Run:

     gcloud iam service-accounts add-iam-policy-binding \
       [email protected] \
       --member="serviceAccount:[email protected]" \
       --role="roles/iam.serviceAccountUser"
    
  9. Run terraform apply

Other Notes

Google Cloud Build is used for a various automatic actions triggered by pushes to the main Github branch:

  • Run Terraform to build any new infrastructure
  • Build Docker image for the Go code and deploy it to GCR
  • Run database migrations