terraform-google-modules/terraform-google-scheduled-function

google_cloudfunctions_function.main : Error : file main.py [...] doesn't exist.

bkamin29 opened this issue · 3 comments

Hello,
I'm systematically encountered an error when running a first terraform apply command from my laptop and after adding a new terraform-google-scheduled-function resource.
I encounter this error by using terraform-google-slo/slo

Trace :

[...]
module.slo-generator.module.slo-hp-fr-latency-1024ms.module.slo-cloud-function.module.main.google_cloudfunctions_function.main: Still creating... [1m40s elapsed]

Error: Error waiting for Creating CloudFunctions Function: Error code 3, message: Function failed on loading user code. Error message: File main.py that is expected to define function doesn't exist

  on .terraform/modules/slo-generator.slo-hp-fr-latency-1024ms.slo-cloud-function.main/terraform-google-modules-terraform-google-event-function-32a9ef5/main.tf line 41, in resource "google_cloudfunctions_function" "main":
  41: resource "google_cloudfunctions_function" "main" {

After re-executing a terraform apply command, the new cloud function is created successfully.

Maybe we don't wait long enough between the event where we push "code" in the storage bucket and the moment where the Clund Function is in creating.
So i have try to add a manual resource dependency (depends_on=) in google_cloudfunctions_function. main, but it's not a success..

I have try to do my terraform apply in two distinct steps :

  • The first without the resource google_cloudfunctions_function.main enabled (in comment)
  • The second, after somes minutes in with uncommented google_cloudfunctions_function.main resource.

And it's work, not more errors with this procedure.

@taylorludwig Could you do some investigation here?

Experiencing same issue. "Same" code on my project worked 4-5 months earlier.