Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 1.83 KB

README.md

File metadata and controls

73 lines (50 loc) · 1.83 KB

cloud-run-app-template

This is a template for a Cloud Run app.

You can initialize a GitHub repository to manage Cloud Run services with Terraform:

  • Deploy a Cloud run service with Terraform
  • Set up a GitHub Actions workflow for the Terraform

Ref: Sample app created with this template

Steps

  1. Create a repo (e.g. cloud-run-app-sample) from this template.

    NEW_REPO=cloud-run-app-sample
    
    gh repo create $NEW_REPO --public --template=nakamasato/cloud-run-app-template
    
    gh repo clone $NEW_REPO
    
  2. Create a GCS bucket for Terraform backend if needed (optional).

    gsutil mb -p "<gcp project>" -l "<region>" gs://"<bucket>"
    
  3. Move to terraform directory.

    cd terraform
    
  4. Write your own config files.

    terraform.tfvars:

    project      = "<gcp project>"
    region       = "<region>"
    service_name = "<Cloud Run service name>"

    terraform.tfbackend:

    bucket  = "<bucket for Terraform state>"
  5. Run terraform init -backend-config=terraform.tfbackend

  6. Run terraform apply.

  7. Set up GitHub Actions secrets PROVIDER_NAME and SA_EMAIL.

    gh secret set PROVIDER_NAME --body=$(terraform output github_actions_provider_name | tr -d '"')
    gh secret set SA_EMAIL --body=$(terraform output github_actions_sa_email | tr -d '"')
    
  8. Push to your repo.

For more details, please read terraform.

Application

TBD

Ref

  1. terraform-google-cloud-run
  2. terraform-google-modules/terraform-google-github-actions-runners