Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Granting access to a Google Cloud Storage bucket to a third-party

I need a third-party to upload some files to a Google Cloud Storage bucket. What is the best (or easiest) way to give them access?

like image 349
markkazanski Avatar asked Nov 01 '18 17:11

markkazanski


People also ask

How do I grant access to the Google Cloud Storage bucket?

In the Google Cloud console, go to the Cloud Storage Buckets page. Click the Bucket overflow menu ( ) associated with the bucket to which you want to grant a principal a role. Choose Edit access. Click the + Add principal button.

How to access Gcp bucket from another project?

To give your Cloud Dataprep project access to a Cloud Storage bucket owned by a different Google Cloud console project, you must make the bucket accessible to the service accounts in your Cloud Dataprep project, and then manually enter that Cloud Storage location in the UI.

How can you control the access to Cloud Storage bucket?

You can use signed URLs in addition to IAM and ACLs. For example, you can use IAM to grant access to a bucket for only a few people, then create a signed URL that allows others to access a specific resource within the bucket.


1 Answers

The first two methods require that the user have a valid Google Account. I am ignoring Google Identity Platform in this answer. If the user has a Gmail Account, then this means they also have a Google Account. The third method uses a Google Service Account.

Method 1: Use the Google Cloud Storage Console:

  • Go to Storage -> Browser.

  • Check the desired bucket. In the right side panel under permissions, click the Add button.

  • Add the user's Google Account email address. Select Storage Object Creator.

The role granted is roles/storage.objectCreator. This role grants the user permissions to create objects in the bucket but the user cannot delete or overwrite objects.

Link to Cloud Storage Roles

Method 2: Use the gsutl CLI:

gsutil iam ch user:[email protected]:ObjectCreator gs://examplebucket

Link to gcloud IAM

Command to read the current bucket IAM policy:

gsutil iam get gs://examplebucket

Method 3: Use a Google Service Account

Create a Google Service Account in the Google Cloud Console

  1. Go to IAM & admin -> Service accounts
  2. Click CREATE SERVICE ACCOUNT
  3. Enter a Service account name and Service account description
  4. Click CREATE
  5. In the next screen Service account permissions, select a role.
  6. Select Storage -> Storage Object Creator
  7. Click CONTINUE
  8. Click Create key
  9. Check the JSON radio button for the Key type
  10. Save the json file to your local computer.

You now have Google Service Account credentials that can be setup with gsutil, gcloud and software programs.

Setting up gcloud with Service Account Credentials

like image 66
John Hanley Avatar answered Sep 19 '22 05:09

John Hanley