This project use pnpm
, typescript
, terraform
If you found this repository useful, please consider giving it a star ⭐️!
-
Clone this repo
git clone git@github.com:samuelint/gcp-cloud-function-terraform-boilerplate.git
-
Setup terraform cloud 2.1 Terraform Cloud login - https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-login 2.2 GCP + Terraform Cloud Auth - https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#running-terraform-on-google-cloud
-
Set Terraform cloud workspace id in
main.tf
(https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-workspace-create) -
terraform plan
,terraform apply
🚀
Deployments are done using terraform.
Execute terraform apply
to deploy the application and update the cloud function code.
Every non-sensitive and non-terraform file is zipped into an archive and deployed to a Google Cloud Storage (GCS) using the cloud-function.tf - data "archive_file" "dist" reference.
Once the file is uploaded, the google cloud function is updated with the new zip file.
Note main.tf
must be at same level as src
, package.json
, dist
, etc... Having a directory terraform file in a subdirectory will result in terraform not being able to find the code to upload. Technically, every files must be under path.module
for terraform cloud to be able to handle code source.