terraform-provider-google: Cloud functions gen2 source repo block does not work 🔢 ❌
Description
It seems its not possible to deploy cloud functions gen 2 using source repositories, there is an error. I am able to deploy a cloud function gen1 using the source repository link but not gen2
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
- Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- If an issue is assigned to the
modular-magicianuser, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot, a community member has claimed the issue already.
Terraform Version
Affected Resource(s)
- google_cloudfunctions2_function
Terraform Configuration Files
resource "google_cloudfunctions2_function" "terraform-test2" {
provider = google-beta
project = local.project
name = "test-function-2"
location = "us-central1"
description = "a new function"
build_config {
runtime = "python39"
entry_point = "run"
source {
repo_source {
project_id = local.project
repo_name = "my-github-repo"
branch_name = "development"
dir = "cf-template"
}
}
}
Debug Output
Error: Error waiting to create function: Error waiting for Creating function: Error code 3, message: Build failed with status: FAILURE and message: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function. For more details see the logs at
Panic Output
Expected Behavior
Function should deploy as normal
Actual Behavior
Error when deploying cloud function
Steps to Reproduce
terraform apply
Important Factoids
References
b/308248099
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 18
- Comments: 18
I encountered the same issue. However, I am able to successfully deploy it after moving
main.pyandrequirements.txtto the root directory of the repository (Cloud Source Repository).This is my folder structure when error occurs:
This arrangement allows the build to complete and the function works as intended, despite
diris set ascloud_functions.The partial debug log is as follows:
That google doc comment is odd, because deploying gen2 cloud functions with
gcloud functions deployworks just fine with--source=<repo_url>and from the UI/web page.It is pretty sad this wasn’t documented because I just rewrote my module to use this after the archive way of handling it failed to work idempotently. I guess API in this case stands for Absolutely Positively Inoperable. :p
Hope it is added soon since it would be a much cleaner solution than a zip file in a bucket.
@burnier is correct, Gen2 currently doesn’t support deploying from a Cloud Source Repository (docs: https://cloud.google.com/functions/docs/deploy#from-source-repo see note) For Gen2 you’d have to use a source bucket.
@rileykarson or @k-ezis any update on this?
We don’t happen to have a test for repo mode, unfortunately- it’s hard to set up + tear down one of 'em in a test.
@k-ezis: If you have a few space cycles, do you spot anything off in that response? Given the API silently rejects one field, I’m a little worried a value in another may be getting silently rejected.