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
-
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
-
Create a GCS bucket for Terraform backend if needed (optional).
gsutil mb -p "<gcp project>" -l "<region>" gs://"<bucket>"
-
Move to
terraform
directory.cd terraform
-
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>"
-
Run
terraform init -backend-config=terraform.tfbackend
-
Run
terraform apply
. -
Set up GitHub Actions secrets
PROVIDER_NAME
andSA_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 '"')
-
Push to your repo.
For more details, please read terraform.
TBD