question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deploy Error: Failed to configure trigger GCS Bucket

See original GitHub issue

Hi, I’m trying out the image resizing demo. Deployment throwing error:

 Deploy Error: Failed to configure trigger GCS Bucket: product_images

My images are inside product_images folder and my code looks like this:


exports.generateThumbnail = functions.storage.object().onChange(event => {
  const object = event.data;
  const fileBucket = object.bucket;
  const filePath = object.name;
  const contentType = object.contentType;
  const resourceState = object.resourceState;

  if(!filePath.match(/product_images/)) {
    console.log('not product_images bucket');
    return;
  }

  if (!contentType.startsWith('image/')) {
    console.log('This is not an image.');
    return;
  }

  const fileName = filePath.split('/').pop();
  // Exit if the image is already a thumbnail.
  if (fileName.startsWith('thumb_')) {
    console.log('Already a Thumbnail.');
    return;
  }

  if (resourceState === 'not_exists') {
    console.log('This is a deletion event.');
    return;
  }

  const bucket = gcs.bucket(fileBucket);
  const tempFilePath = `/tmp/${fileName}`;

  return bucket.file(filePath).download({
    destination: tempFilePath
  }).then(() => {
    console.log('Image downloaded locally to', tempFilePath);
    // Generate a thumbnail using ImageMagick.
    return spawn('convert', [tempFilePath, '-thumbnail', '64x64>', tempFilePath]).then(() => {
      console.log('Thumbnail created at', tempFilePath);
      // We add a 'thumb_' prefix to thumbnails file name. That's where we'll upload the thumbnail.
      const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, `$1thumb_$2`);
      // Uploading the thumbnail.
      return bucket.upload(tempFilePath, {
        destination: thumbFilePath
      });
    });
  });
});

Not sure what it means.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
aldoromo88commented, May 10, 2018

I was having the same problem. Apparently it is caused by missing permission on service account executing cloud function.

I just added Storage Object Admin role to default to default service account and everything start to work as expected.
image

1reaction
nicolasgarniercommented, Apr 3, 2017

FYI this issue is somewhat widespread because we used to have a bug (as of 1-2 month ago) where lots of Cloud Storage Buckets were created with the wrong permissions. New projects don’t have this issue but if you have an old Firebase project which is impacted by this the manual fix for your permissions is described here:

https://github.com/firebase/friendlychat/issues/184#issuecomment-290914672

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR: Failed to configure trigger GCS Bucket - Stack Overflow
NOTE: Already tried Disable & Re-enable Cloud Functions API. both GCS Bucket & Cloud Function is in same project.
Read more >
Failed to configure trigger GCS Bucket · Issue #1103 - GitHub
This error looks project-specific. Please reach out to Firebase support for help, as the issue likely lies with the backend servers and not...
Read more >
Troubleshooting build errors | Cloud Build Documentation
Build triggers use the Cloud Build service account to create a build. The error above indicates that the Cloud Build service account is...
Read more >
Trigger bucket in a different Project [70628944] - Issue Tracker
"(gcloud.beta.functions.deploy) OperationError: code=13, message=Failed to configure trigger GCS Bucket:[different-project-trigger-bucket]" ...
Read more >
A Step-by-Step Guide to Building and Deploying Google ...
We'll set up a cloud function in Python that listens for a new upload event to a specific Google Cloud Storage bucket. Next,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found