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

[Core][AWS] Allow specification of IAM roles for resources. #3488

Merged
merged 15 commits into from
May 7, 2024

Conversation

JGSweets
Copy link
Contributor

@JGSweets JGSweets commented Apr 26, 2024

This PR updates the schema config to allow specification of IAM roles for resources based on the skypilot naming conventions.

Address: #3487

In ~/.sky/config.yaml:

  • When setting for the controller and all other resources (default)
aws:
  remote_identity:
    sky-serve-controller-*: skypilot-v1-fake
    "*": skypilot-default-fake
  • When setting for everything by specifying a default
aws:
  remote_identity:
    "*": skypilot-default-fake
  • When setting for everything by specifying just the remote_identity via string
aws:
  remote_identity: skypilot-default-fake
  • When first profile doesn't match it chooses the next in line if viable
aws:
  remote_identity:
    does-not-match: skypilot-default-fake
    "*": skypilot-default-fake

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
    • tested running in all 4 configs in AWS
      • Nothing set
      • setting different controller and default values
      • setting default only
      • setting two profile names where the first one doesn't match to ensure it selects the viable candidate in order
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

@JGSweets JGSweets changed the title [CORE][AWS] Allow specification of IAM roles for resources. [Core][AWS] Allow specification of IAM roles for resources. Apr 26, 2024
@JGSweets
Copy link
Contributor Author

JGSweets commented May 2, 2024

Due note the quotes required around * to meet yaml file specifications: "*".

e.g.

aws:
  remote_identity:
    "*": skypilot-default-fake

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this @JGSweets! The code looks good to me. Could you help add the new schema in our docs as well: https://skypilot.readthedocs.io/en/latest/reference/config.html

i.e., the following code path:

remote_identity: LOCAL_CREDENTIALS

if remote_identity == 'SERVICE_ACCOUNT':
if remote_identity is not None and not isinstance(remote_identity, str):
for profile in remote_identity:
if fnmatch.fnmatchcase(cluster_name_on_cloud, profile):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to match cluster_name instead cluster_name_on_cloud as the former is user-facing and should be more intuitive to stay the same as the one specified in ~/.sky/config.yaml.

Suggested change
if fnmatch.fnmatchcase(cluster_name_on_cloud, profile):
if fnmatch.fnmatchcase(cluster_name, profile):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

sky/backends/backend_utils.py Show resolved Hide resolved
Comment on lines +522 to +528
}, {
'type': 'object',
'required': [],
'additionalProperties': {
'type': 'string',
},
}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we only added the support for AWS at the moment, we should limit this ability to aws cloud only, i.e. in L664, we can only apply this additional support for aws only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed

Comment on lines 123 to 124
# User Specified SERVICE_ACCOUNT (IAM role): The name of the remote identity
# to give the launched resouce.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how we wanted to reference this specifically as an example. Open to suggestion here.

Comment on lines 137 to 148
### Format 1 ###
# A string; the same remote identity is applied to all launched resources.
remote_identity: LOCAL_CREDENTIALS
### Format 2 ###
# A dict mapping wildcard expression of cloud names to the resources to the
# resource identity.
# NOTE: If not a wildcard expression in the dict mapping does not match a
# cloud name for a resouce being deployed, the default remote identity is used.
# To specify your own default, utilize "*" as the wildcard expression.
remote_identity:
sky-serve-controller-*: my-controller-specific-identity
"*": SERVICE_ACCOUNT
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First attempt at how we represent multiple formats.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these! I reorganized the comments a little bit in the comment above, can we remove Format 1 and Format 2 here and use the comments above?

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix @JGSweets! This PR should be good to go with the comments fixed. : )

docs/source/reference/config.rst Outdated Show resolved Hide resolved
Comment on lines 137 to 148
### Format 1 ###
# A string; the same remote identity is applied to all launched resources.
remote_identity: LOCAL_CREDENTIALS
### Format 2 ###
# A dict mapping wildcard expression of cloud names to the resources to the
# resource identity.
# NOTE: If not a wildcard expression in the dict mapping does not match a
# cloud name for a resouce being deployed, the default remote identity is used.
# To specify your own default, utilize "*" as the wildcard expression.
remote_identity:
sky-serve-controller-*: my-controller-specific-identity
"*": SERVICE_ACCOUNT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these! I reorganized the comments a little bit in the comment above, can we remove Format 1 and Format 2 here and use the comments above?

docs/source/reference/config.rst Outdated Show resolved Hide resolved
JGSweets and others added 3 commits May 6, 2024 19:34
refactor: config description

Co-authored-by: Zhanghao Wu <[email protected]>
refactor: config example

Co-authored-by: Zhanghao Wu <[email protected]>
@JGSweets
Copy link
Contributor Author

JGSweets commented May 7, 2024

@Michaelvll Fixed as suggested. Thanks for the improvements!

@Michaelvll Michaelvll merged commit 5a0ecc7 into skypilot-org:master May 7, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants