@@ -690,26 +690,56 @@ def write_cluster_config(
690
690
skypilot_config .get_nested (
691
691
(str (to_provision .cloud ).lower (), 'specific_reservations' ), set ()))
692
692
693
+ # Remote identity handling can have 4 cases:
694
+ # 1. LOCAL_CREDENTIALS (default for most clouds): Upload local credentials
695
+ # 2. SERVICE_ACCOUNT: SkyPilot creates and manages a service account
696
+ # 3. Custom service account: Use specified service account
697
+ # 4. NO_UPLOAD: Do not upload any credentials
698
+ #
699
+ # We need to upload credentials only if LOCAL_CREDENTIALS is specified. In
700
+ # other cases, we exclude the cloud from credential file uploads after
701
+ # running required checks.
693
702
assert cluster_name is not None
694
- excluded_clouds = []
703
+ excluded_clouds = set ()
695
704
remote_identity_config = skypilot_config .get_nested (
696
705
(str (cloud ).lower (), 'remote_identity' ), None )
697
706
remote_identity = schemas .get_default_remote_identity (str (cloud ).lower ())
698
707
if isinstance (remote_identity_config , str ):
699
708
remote_identity = remote_identity_config
700
709
if isinstance (remote_identity_config , list ):
710
+ # Some clouds (e.g., AWS) support specifying multiple service accounts
711
+ # chosen based on the cluster name. Do the matching here to pick the
712
+ # correct one.
701
713
for profile in remote_identity_config :
702
714
if fnmatch .fnmatchcase (cluster_name , list (profile .keys ())[0 ]):
703
715
remote_identity = list (profile .values ())[0 ]
704
716
break
705
717
if remote_identity != schemas .RemoteIdentityOptions .LOCAL_CREDENTIALS .value :
706
- if not cloud .supports_service_account_on_remote ():
718
+ # If LOCAL_CREDENTIALS is not specified, we add the cloud to the
719
+ # excluded_clouds set, but we must also check if the cloud supports
720
+ # service accounts.
721
+ if remote_identity == schemas .RemoteIdentityOptions .NO_UPLOAD .value :
722
+ # If NO_UPLOAD is specified, fall back to default remote identity
723
+ # for downstream logic but add it to excluded_clouds to skip
724
+ # credential file uploads.
725
+ remote_identity = schemas .get_default_remote_identity (
726
+ str (cloud ).lower ())
727
+ elif not cloud .supports_service_account_on_remote ():
707
728
raise exceptions .InvalidCloudConfigs (
708
729
'remote_identity: SERVICE_ACCOUNT is specified in '
709
730
f'{ skypilot_config .loaded_config_path !r} for { cloud } , but it '
710
731
'is not supported by this cloud. Remove the config or set: '
711
732
'`remote_identity: LOCAL_CREDENTIALS`.' )
712
- excluded_clouds = [cloud ]
733
+ excluded_clouds .add (cloud )
734
+
735
+ for cloud_str , cloud_obj in cloud_registry .CLOUD_REGISTRY .items ():
736
+ remote_identity_config = skypilot_config .get_nested (
737
+ (cloud_str .lower (), 'remote_identity' ), None )
738
+ if remote_identity_config :
739
+ if (remote_identity_config ==
740
+ schemas .RemoteIdentityOptions .NO_UPLOAD .value ):
741
+ excluded_clouds .add (cloud_obj )
742
+
713
743
credentials = sky_check .get_cloud_credential_file_mounts (excluded_clouds )
714
744
715
745
auth_config = {'ssh_private_key' : auth .PRIVATE_SSH_KEY_PATH }
0 commit comments