GCP Error waiting for Creating function: Error code 13: Build failed with status: FAILURE and message: An unexpected error occurred

I’m trying to deploy a Google Cloud Function but it keeps failing in one particular project, which we use for production whereas it works fine in a test project. It fails in the exact same way regardless whether I create it with Terraform or clicking in the UI. The service account is correct and has all the necessary permissions.

When I go to Cloud Functions, I can see the function with a red exclamation mark on the left and message: This function has failed to deploy and will not work correctly. Please edit and redeploy.

Having expanded that message, it says: Cloud Run service projects/<project-id>/locations/us-west3/services/function-1-test for the function was not found. The function will not work correctly. Please redeploy.

And another message: Build failed with status: FAILURE and message: An unexpected error occurred. Refer to build logs: <url>. For more details see the logs at <url>.

The logs are empty, not a single entry. In Cloud Build, I can see that it gets stuck on fetch step. No logs either.

When creating resources with Terraform, everything gets created successfully and it fails on creating the Cloud Function with a message: Error: Error waiting to create function: Error waiting for Creating function: Error code 13, message: Build failed with status: FAILURE and message: An unexpected error occurred. Etc etc.

Leave a Comment