Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AWS] Fix config syntax for IAM profile #3514

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions docs/source/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,20 @@ Available fields and semantics:
# instances. SkyPilot will auto-create and reuse a service account (IAM
# role) for AWS instances.
#
# Customized service account (IAM role): <string> or <dict>
# Customized service account (IAM role): <string> or <list of single-element dict>
# - <string>: apply the service account with the specified name to all instances.
# Example:
# remote_identity: my-service-account-name
# - <dict>: A dict mapping from the cluster name (pattern) to the service account name to use.
# NOTE: If none of the wildcard expressions in the dict match the cluster name, LOCAL_CREDENTIALS will be used.
# To specify your default, use "*" as the wildcard expression.
# Example:
# - <list of single-element dict>: A list single-element dict mapping from the cluster name (pattern)
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
# to the service account name to use. The matching of the cluster name is done in the same order
# as the list.
# NOTE: If none of the wildcard expressions in the dict match the cluster name, LOCAL_CREDENTIALS will be used.
# To specify your default, use "*" as the wildcard expression.
# Example:
# remote_identity:
# my-cluster-name: my-service-account-1
# sky-serve-controller-*: my-service-account-2
# "*": my-default-service-account
# - my-cluster-name: my-service-account-1
# - sky-serve-controller-*: my-service-account-2
# - "*": my-default-service-account
#
# Two caveats of SERVICE_ACCOUNT for multicloud users:
#
Expand Down
4 changes: 2 additions & 2 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,8 @@ def write_cluster_config(
(str(cloud).lower(), 'remote_identity'), 'LOCAL_CREDENTIALS')
if remote_identity is not None and not isinstance(remote_identity, str):
for profile in remote_identity:
if fnmatch.fnmatchcase(cluster_name, profile):
remote_identity = remote_identity[profile]
if fnmatch.fnmatchcase(cluster_name, list(profile.keys())[0]):
remote_identity = list(profile.values())[0]
break
if remote_identity != 'LOCAL_CREDENTIALS':
if not cloud.supports_service_account_on_remote():
Expand Down
4 changes: 3 additions & 1 deletion sky/skypilot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def _try_load_config() -> None:
common_utils.validate_schema(
_dict,
schemas.get_config_schema(),
f'Invalid config YAML ({config_path}): ',
f'Invalid config YAML ({config_path}). See: '
'https://skypilot.readthedocs.io/en/latest/reference/config.html. ' # pylint: disable=line-too-long
'Error: ',
skip_none=False)

logger.debug('Config syntax check passed.')
Expand Down
21 changes: 16 additions & 5 deletions sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,22 @@ def get_cluster_schema():
'remote_identity': {
'oneOf': [{
'type': 'string'
}, {
'type': 'object',
'required': [],
'additionalProperties': {
'type': 'string',
},
{
# A list of single-element dict to pretain the order.
# Example:
# remote_identity:
# - my-cluster1-*: my-iam-role-1
# - my-cluster2-*: my-iam-role-2
# - *: my-iam-role-3
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
'type': 'array',
'items': {
'type': 'object',
'additionalProperties': {
'type': 'string'
},
'maxProperties': 1,
'minProperties': 1,
},
}]
}
Expand Down
Loading