Skip to content

Fix Estimator role expansion #68

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

Merged
merged 1 commit into from
Feb 2, 2018
Merged
Changes from all 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
7 changes: 3 additions & 4 deletions src/sagemaker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ def endpoint_from_production_variants(self, name, production_variants, wait=True
def expand_role(self, role):
"""Expand an IAM role name into an ARN.

If the role is already in the form of an ARN, then the role is simply returned. Otherwise, the role
is formatted as an ARN, using the current account as the IAM role's AWS account.
If the role is already in the form of an ARN, then the role is simply returned. Otherwise we retrieve the full
ARN and return it.

Args:
role (str): An AWS IAM role (either name or full ARN).
Expand All @@ -534,8 +534,7 @@ def expand_role(self, role):
if '/' in role:
return role
else:
account = self.boto_session.client('sts').get_caller_identity()['Account']
return 'arn:aws:iam::{}:role/{}'.format(account, role)
return boto3.resource("iam").Role(role).arn

def get_caller_identity_arn(self):
"""Returns the ARN user or role whose credentials are used to call the API.
Expand Down