Skip to content

Commit

Permalink
[Core][AWS] Allow assumption of AWS Credentials provided in ECS Conta…
Browse files Browse the repository at this point in the history
…iners (#3503)

* feat: add container-role

* fix: comment

* fix: update gitignore to include .env files
  • Loading branch information
JGSweets authored May 8, 2024
1 parent 071614a commit 40a0f57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sky_logs/
sky/clouds/service_catalog/data_fetchers/*.csv
.vscode/
.idea/

.env
10 changes: 10 additions & 0 deletions sky/clouds/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class AWSIdentityType(enum.Enum):

IAM_ROLE = 'iam-role'

CONTAINER_ROLE = 'container-role'

# Name Value Type Location
# ---- ----- ---- --------
# profile <not set> None None
Expand Down Expand Up @@ -545,6 +547,12 @@ def check_credentials(cls) -> Tuple[bool, Optional[str]]:
# jobs-controller) created by an SSO account, i.e. the VM will be
# assigned the IAM role: skypilot-v1.
hints = f'AWS IAM role is set.{single_cloud_hint}'
elif identity_type == AWSIdentityType.CONTAINER_ROLE:
# Similar to the IAM ROLE, an ECS container may not store credentials
# in the~/.aws/credentials file. So we don't check for the existence of
# the file. i.e. the container will be assigned the IAM role of the
# task: skypilot-v1.
hints = f'AWS container-role is set.{single_cloud_hint}'
else:
# This file is required because it is required by the VMs launched on
# other clouds to access private s3 buckets and resources like EC2.
Expand Down Expand Up @@ -604,6 +612,8 @@ def _is_access_key_of_type(type_str: str) -> bool:
return AWSIdentityType.SSO
elif _is_access_key_of_type(AWSIdentityType.IAM_ROLE.value):
return AWSIdentityType.IAM_ROLE
elif _is_access_key_of_type(AWSIdentityType.CONTAINER_ROLE.value):
return AWSIdentityType.CONTAINER_ROLE
elif _is_access_key_of_type(AWSIdentityType.ENV.value):
return AWSIdentityType.ENV
else:
Expand Down

0 comments on commit 40a0f57

Please sign in to comment.