Using non-default service account in Google Cloud dataproc

mancaus

I'd like to create a dataproc cluster that runs under a non-default service account. The following works for a compute instance:

gcloud compute instances create instance-1 --machine-type "n1-standard-1" --zone "europe-west1-b" --scopes [email protected]="https://www.googleapis.com/auth/cloud-platform"

But the same --scopes argument fails when creating a dataproc instance:

gcloud dataproc clusters create --zone "europe-west1-b" --scopes [email protected]="https://www.googleapis.com/auth/cloud-platform" testdataproc12345

ERROR: (gcloud.dataproc.clusters.create) Invalid service account scope: '[email protected]=https://www.googleapis.com/auth/cloud-platform'

Is it possible to run dataproc under a non-default service account?

Dennis Huo

Unfortunately, at the moment there's no way to specify your custom service accounts using the normal "scopes and metadata"-mediated auth setup. This is a known feature request, however, so it should become available in a future Dataproc update.

In the meantime, even though you can't disable the existence of the "storage read/write" scope with the default GCE service account when using Dataproc, you can make the Hadoop side use a particular service account via keyfiles by using the "Create Key" option under the IAM & Admin > Service accounts page to obtain a JSON keyfile for your service account, and then do two things:

  1. Add the following property at cluster creation time:

    --properties core:fs.gs.auth.service.account.json.keyfile=/etc/hadoop/conf/my-service-account.json
    
  2. Use an init action which copies your JSON keyfile to your nodes; note that this still means your JSON keyfile must be accessible to the GCE default service account as a reader, and anyone who has access to the GCS location of your JSON keyfile also has the ability to now act on behalf of that service account, so you still need to keep your project secure as necessary.

    #!/bin/bash
    # Save this somewhere as gs://somepath/my-keyfile-setup.sh
    
    gsutil cp gs://path/to/your/json/file/in/gcs/my=service-account.json \
        /etc/hadoop/conf/my-service-account.json
    

    And then apply that init action:

    gcloud dataproc clusters create --initialization-actions gs://somepath/my-keyfile-setup.sh ...
    

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to use service account with google cloud print

From Dev

Google Cloud Storage with Service account - 403 Forbidden

From Dev

Powershell for Google Cloud: Authenticate with a service account

From Dev

Default Compute Engine service account cant access Cloud SQL

From Dev

Using Advanced Google Services with Service Account

From Dev

Google Cloud Dataproc configuration issues

From Dev

Google Cloud Dataproc - Encryption in transit?

From Dev

How to recover Google App Engine's "default service account"

From Dev

How to recover Google App Engine's "default service account"

From Dev

Authenticate as a service account from Android app for Google Cloud Storage

From Dev

Google Cloud Vision API - How to enable a service account

From Dev

How to use Service Account to authenticate with Google Cloud SQL Java

From Dev

Authenticate Chrome extension with non-Google API using Google account

From Dev

Google Credential Service Account

From Dev

Google Service Account

From Dev

Google Service Account

From Dev

Google Cloud Dataproc - Spark and Hadoop Version

From Dev

Add contact using contact app to a non google account

From Dev

Add contact using contact app to a non google account

From Dev

Unable to query Google Search Console API using a Service Account

From Java

How to move a file in a shared google drive to trash using a service account

From Dev

Create users using Service Account with Google Admin SDK?

From Dev

Enable mail forwarding using a Google Apps Service Account

From Dev

Ownership of Google Drive files and Service Account using API

From Dev

Create users using Service Account with Google Admin SDK?

From Dev

Google Classroom using Service Account with domain-wide-delegation

From Dev

How to change the scope of a Google Compute Engine service account to write data to a Google Cloud Storage bucket?

From Dev

How to fetch data of My own Google Analytics Account using Service account keys?

From Dev

How can I authorize a Google Service Account without the default credentials file?

Related Related

  1. 1

    Is it possible to use service account with google cloud print

  2. 2

    Google Cloud Storage with Service account - 403 Forbidden

  3. 3

    Powershell for Google Cloud: Authenticate with a service account

  4. 4

    Default Compute Engine service account cant access Cloud SQL

  5. 5

    Using Advanced Google Services with Service Account

  6. 6

    Google Cloud Dataproc configuration issues

  7. 7

    Google Cloud Dataproc - Encryption in transit?

  8. 8

    How to recover Google App Engine's "default service account"

  9. 9

    How to recover Google App Engine's "default service account"

  10. 10

    Authenticate as a service account from Android app for Google Cloud Storage

  11. 11

    Google Cloud Vision API - How to enable a service account

  12. 12

    How to use Service Account to authenticate with Google Cloud SQL Java

  13. 13

    Authenticate Chrome extension with non-Google API using Google account

  14. 14

    Google Credential Service Account

  15. 15

    Google Service Account

  16. 16

    Google Service Account

  17. 17

    Google Cloud Dataproc - Spark and Hadoop Version

  18. 18

    Add contact using contact app to a non google account

  19. 19

    Add contact using contact app to a non google account

  20. 20

    Unable to query Google Search Console API using a Service Account

  21. 21

    How to move a file in a shared google drive to trash using a service account

  22. 22

    Create users using Service Account with Google Admin SDK?

  23. 23

    Enable mail forwarding using a Google Apps Service Account

  24. 24

    Ownership of Google Drive files and Service Account using API

  25. 25

    Create users using Service Account with Google Admin SDK?

  26. 26

    Google Classroom using Service Account with domain-wide-delegation

  27. 27

    How to change the scope of a Google Compute Engine service account to write data to a Google Cloud Storage bucket?

  28. 28

    How to fetch data of My own Google Analytics Account using Service account keys?

  29. 29

    How can I authorize a Google Service Account without the default credentials file?

HotTag

Archive