8

I am in the process of attempting to adjust user permissions in Google Cloud and have created a service account that other users can impersonate to access various projects. The gcloud command has the --impersonate-service-account option to make API calls with the proper authentication, but I was wondering if anyone knows how to make such calls using gsutil.

Here's an example of what a successful call looks like using gcloud:

gcloud --impersonate-service-account=superuser@PROJECT1.iam.gserviceaccount.com iam service-accounts list --project PROJECT2
bboe
  • 4,092
  • 3
  • 29
  • 39

2 Answers2

15

Yes, here's the option:

$ gsutil -i [SERVICE-ACCOUNT]@[PROJECT] [GSUTIL-COMMAND]

Example:

$ gsutil -i myserviceaccount@iam.gserviceaccount.com ls
Das_Geek
  • 2,775
  • 7
  • 20
  • 26
Fer
  • 166
  • 1
  • 2
3

There is no such option in the top-level gsutil command-line options (at least not a documented one).

By contrast the gcloud --impersonate-service-account is documented.

Things to try:

-e Prompt for service account credentials. This option requires that -a is not set.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • 1
    I previously tried the things you suggested and have come to a similar conclusion that as of now, no such feature exists. I opened this issue on the gsutil github project: https://github.com/GoogleCloudPlatform/gsutil/issues/813 Thanks! – bboe Jun 19 '19 at 05:03