0

I am using terraform to deploy a python cloud function, similar to the official example, things are working as expected but now I want to use protobuf, which requires extra compile step, I know cloud function is built using cloud build and I am trying to squeeze the proto compiler command into it.

the terraform build_config doesn't seems to take in a custom cloudbuild.yaml but I added one anyway, under my functions root directory as suggested by Gemini, however it didn't work, I checked the latest cloud build log and my changes did not take effect.

My current workaround is to compile the proto file in my local working directory before the function zip is created and uploaded, but I would like to automate it.

1 Answer 1

1

Terraform doesn’t support a custom cloudbuild.yaml in google_cloudfunctions_function. Your current workaround—compiling the proto files locally before creating and uploading the function zip—is the correct approach.

To automate this, you can use a null_resource with a local-exec provisioner in Terraform. This will run the protobuf compilation and zip commands before deployment. Then, use source_archive_bucket and source_archive_object to deploy the zipped function to Cloud Functions.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, I didn't know about the local-exec provisioner, but I was going through their doc, it executes command AFTER a resource is created, isn't that too late? I want to run the proto compiler before zip, before anything is uploaded

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.