tmastny / sagemaker

AWS Sagemaker R Interface
https://tmastny.github.io/sagemaker/
Other
7 stars 0 forks source link

Sagemaker doesn't add the execution role to my profile #5

Closed jcpsantiago closed 4 years ago

jcpsantiago commented 4 years ago

I have a profile already set in ~/.aws/credentials because my company uses Okta for single sign-on. Saving a new execution role with sagemaker_save_execution_role("arn:aws:iam::xxxxxx:role/service-role/AmazonSageMaker-ExecutionRole-20200513T120887") appends this role to ~/.aws/config (it doesn't check if it already exists so it duplicates it, but that's another story) without naming the profile I set with

options(sagemaker.default.role.profile = "my-profile")

This results in sagemaker_get_execution_role() returning arn:aws:iam::xxxxx:role/Administrator instead of arn:aws:iam::xxxxxx:role/service-role/AmazonSageMaker-ExecutionRole-20200513T120887.

Manually editing the file to:

[profile my-profile]                                                                    
role_arn = arn:aws:iam::xxxxxx:role/service-role/AmazonSageMaker-ExecutionRole-20200513T120887    

Makes sagemaker_get_execution_role() return the correct role, although other functions stopped working, example:

> sagemaker_xgb_estimator()

> You are not in a sagemaker hosted notebook.
  Pulling local role in ~/.aws/config
  Error in py_call_impl(callable, dots$args, dots$keywords) : 
   PartialCredentialsError: Partial credentials found in assume-role, missing: source_profile or credential_source
jcpsantiago commented 4 years ago

I think I encountered some cache invalidation issue. After restarting everything worked as it should, except of the duplication. I'll try to make a PR for that.