@@ -66,6 +66,7 @@ def __init__(
66
66
preemptible = False ,
67
67
instance_labels = None ,
68
68
service_account = None ,
69
+ instance_scopes = None ,
69
70
** kwargs ,
70
71
):
71
72
super ().__init__ (** kwargs )
@@ -105,6 +106,7 @@ def __init__(
105
106
106
107
self .general_zone = "-" .join (self .zone .split ("-" )[:2 ]) # us-east1-c -> us-east1
107
108
self .service_account = service_account or self .config .get ("service_account" )
109
+ self .instance_scopes = instance_scopes or self .config .get ("instance_scopes" )
108
110
109
111
def create_gcp_config (self ):
110
112
subnetwork = f"projects/{ self .network_projectid } /regions/{ self .general_zone } /subnetworks/{ self .network } "
@@ -144,11 +146,7 @@ def create_gcp_config(self):
144
146
"serviceAccounts" : [
145
147
{
146
148
"email" : self .service_account ,
147
- "scopes" : [
148
- "https://www.googleapis.com/auth/devstorage.read_write" ,
149
- "https://www.googleapis.com/auth/logging.write" ,
150
- "https://www.googleapis.com/auth/monitoring.write" ,
151
- ],
149
+ "scopes" : self .instance_scopes ,
152
150
}
153
151
],
154
152
# Metadata is readable from the instance and allows you to
@@ -516,6 +514,11 @@ class GCPCluster(VMCluster):
516
514
service_account: str
517
515
Service account that all VMs will run under.
518
516
Defaults to the default Compute Engine service account for your GCP project.
517
+ instance_scopes: list (optional)
518
+ List of GCP OAuth scopes to assign to the service account on instances.
519
+ Defaults to ``["https://www.googleapis.com/auth/devstorage.read_write",
520
+ "https://www.googleapis.com/auth/logging.write",
521
+ "https://www.googleapis.com/auth/monitoring.write"]``.
519
522
service_account_credentials: Optional[Dict[str, Any]]
520
523
Service account credentials to create the compute engine Vms
521
524
@@ -617,6 +620,7 @@ def __init__(
617
620
debug = False ,
618
621
instance_labels = None ,
619
622
service_account = None ,
623
+ instance_scopes = None ,
620
624
service_account_credentials : Optional [Dict [str , Any ]] = None ,
621
625
** kwargs ,
622
626
):
@@ -717,6 +721,7 @@ def __init__(
717
721
),
718
722
"instance_labels" : instance_labels or self .config .get ("instance_labels" ),
719
723
"service_account" : service_account or self .config .get ("service_account" ),
724
+ "instance_scopes" : instance_scopes or self .config .get ("instance_scopes" ),
720
725
}
721
726
self .scheduler_options = {** self .options }
722
727
self .scheduler_options ["machine_type" ] = self .scheduler_machine_type
0 commit comments