Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Errors deploying Google Cloud Functions - Please Assist

So I'm just really trying to learn more about google chat bots - I've built a few bots for discord at this point, and I found what looked like a decent tutorial, that even adds some AI calls.

https://github.com/GQueues/build-a-google-chat-bot-with-chatgpt/tree/main/mod_1_chat#readme

In order to follow the tutorial, I had to create a Workspace account for myself, as I'm not affiliated with any organizations that would have one already set up, which means handling permissions and things like that are all on me.

I was able to fix some errors with deployment (Literally stuck on step 8 of the guide), but now I'm running into one I can't solve.

Trying to deploy returns this error:

Build failed: Build error details not available.Please check the logs at https://console.cloud.google.com/cloud-build/builds;region=us-central1/fb6483d5-a4f4-4965-a63e-6ccb2.... Please visit https://cloud.google.com/functions/docs/troubleshooting#build for in-depth troubleshooting documentation for build related errors.

And trying to look at the logs just shows this:

The service account running this build does not have permission to write logs. To fix this, grant the Logs Writer (roles/logging.logWriter) role to the service account.

My service account is listed under the Cloud Functions details as chatgpt-bot-429817@appspot.gserviceaccount.com, so I went to the IAM configuration page, and added the service account as a new principal, and added Logs Writer as a role. Redeploying doesn't seem to have changed anything.

Any help would be hugely appreciated, this is the second time I've tried to build a google chat bot (first time was using app script) and I ended up just using webhooks as the configuration issues were so challenging.

Thanks

0 1 571
1 REPLY 1

Hi @paper_kitty,

Welcome to Google Cloud Community!

There are several scenarios why you might still get the error: The service account running this build does not have permission to write logs. To fix this, grant the Logs Writer (roles/logging.logWriter) role to the service account. even after adding the Logs Writer role (roles/logging.logWriter) to the service account.

The build service account needs permission to read from the source bucket and read and write permissions for the Artifact Deployment repository. You may encounter this error due to a change in the default behavior for how Cloud Build uses service accounts, detailed in Cloud Build service account change.

To resolve this issue, you can try any of these solutions:

  1. Create a custom build service account for function deployments.
  2. Add the Cloud Build Service Account role (roles/cloudbuild.builds.builder) to the default Compute Engine service account.
  3. Double check that you're using the correct service account credential in your code or configuration. Ensure that it is the same service account where you granted the role
  4. Sometimes, it can take a few minutes for the role changes to propagate across GCP. Wait for a few minutes and then try again.

You can visit Cloud Function troubleshooting for in-depth troubleshooting documentation for build related errors.

I hope the above information is helpful.