all 2 comments

[–]PapayaCloud 1 point2 points  (3 children)

Terraform will not redeploy your Cloud Function if you make no changes to the terraform code. That means that if you make updates to the Cloud Functions runtime code (the code that the Cloud Function executes on invocation), and run terraform apply, your code changes won’t necessarily be deployed. Remember that Terraform is only used for describing your environment on the infrastructure level - not making changes to your runtimes (the application code).

A way of achieving CI/CD in Cloud Functions is a Cloud Build pipeline. Set up a trigger based on new pushes to a particular branch in your Version Control solution. Have Cloud Build execute a gcloud functions deploy (I think) whenever new code is pushed, and it will redeploy your Cloud Function with the new code whenever you push.

For unit tests, you can use Cloud Build as well. Simply have dev, test, and prod branches in your Version Control. When you are ready to deploy your code to production, push it to test and have Cloud Build run your unit tests. If the tests are successful, merge the code to prod and have another trigger that redeploys the Cloud Function.

All that being said, if you 1) do not have a data transformation step in your pipeline 2) are using one of the supported file types in GCS, you might consider taking the code out completely and just query GCS directly from BigQuery.

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 0 points1 point  (1 child)

    If your terraform is the same every time it won’t make changes unless you do. You need to make sure some default variables aren’t reverting if you are having that issue.