# Google\_cloudfunctions2\_function: How to avoid build\_config -\> source providing

**URL:** <https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876>\
**Category:** Terraform\
**Created:** [March 17, 2025, 9:05am UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876 "2025-03-17T09:05:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maxlotl](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxlotl/32/45128_2.png) [@Maxlotl](https://discuss.hashicorp.com/u/Maxlotl)\
**Post date:** [March 17, 2025, 9:05am UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876/1 "2025-03-17T09:05:32Z")

</div>

I would like to use google\_cloudfunctions2\_function just with container registry (point to specific image), but for some strange reason, it’s not possible and I should provide build\_config with source.  
My sources are placed in github and this is a nightmare to understand which permissions, to which SA and how should I provide to allow cloud builder to access github and, unfortunately, I failed to understand how to do that.

So the questions:

1. is it somehow possible to avoid providing source for build\_config or avoid cloud\_build and cause google\_cloudfunctions2\_function to use pre-build image from container registry ?
2. Any guide what is the right way to make bouild\_config → source to work properly with github ?

Thank you in advance !!!

---

<div class="post-metadata">

**Author:** ![wyardley](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/wyardley/32/21845_2.png) [@wyardley](https://discuss.hashicorp.com/u/wyardley)\
**Post date:** [March 17, 2025, 3:52pm UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876/2 "2025-03-17T15:52:41Z")

</div>

This is a pretty common problem. Maybe someone’s got a better idea, but I’ve seen it approached a couple of different ways

1. Use a CI pipeline to deploy the function in an idempotent way, and don’t try to manage it in Terraform at all. This has some downsides… including that you’ll likely have to hard-code the function name or use data resources for related permissions, etc., and you’ll potentially need to hard code things like service account names in the CI configs. This is usually my preferred way to do it, though, all things being equal.

2. Deploy a placeholder / “sentinel” function (just a skeleton with some simple “hello world” code, or whatever) from a zip file or from GCS in the Terraform code, then update the function’s code from your deploy pipeline.

---

<div class="post-metadata">

**Author:** ![Maxlotl](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxlotl/32/45128_2.png) [@Maxlotl](https://discuss.hashicorp.com/u/Maxlotl)\
**Post date:** [March 17, 2025, 7:27pm UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876/3 "2025-03-17T19:27:36Z")

</div>

thank you for answer ! This is really appreciated. I found another solution - just to use google\_cloud\_run\_v2\_service instead of google\_cloudfunctions2\_function

---

<div class="post-metadata">

**Author:** ![wyardley](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/wyardley/32/21845_2.png) [@wyardley](https://discuss.hashicorp.com/u/wyardley)\
**Post date:** [March 19, 2025, 11:29pm UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876/4 "2025-03-19T23:29:13Z")

</div>

Ah, yeah, I missed that… yes, you should use that too. I’m guessing that doc was created before the new resource types existed.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [April 18, 2025, 11:29pm UTC](https://discuss.hashicorp.com/t/google-cloudfunctions2-function-how-to-avoid-build-config-source-providing/73876/5 "2025-04-18T23:29:17Z")

</div>

Closed on April 18, 2025, 11:29pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
