onelogin / onelogin-aws-cli-assume-role

MIT License
29 stars 38 forks source link

-f custom path argument on Windows dont work, fail on profile write #10

Closed cornebester closed 6 years ago

cornebester commented 6 years ago

Tested both Powershell and CMD shells with and without a period in foldername

....
AWS Region (us-west-2): us-east-1
Exception in thread "main" com.amazonaws.SdkClientException: Unable to restore the original credentials file. File content stashed in C:\scratch\aws.bak.a742c34a-f9b6-45c3-97bd-ef39dabd60a0
        at com.amazonaws.auth.profile.ProfilesConfigFileWriter.modifyProfiles(ProfilesConfigFileWriter.java:232)
        at com.amazonaws.auth.profile.ProfilesConfigFileWriter.modifyOneProfile(ProfilesConfigFileWriter.java:129)
        at com.onelogin.aws.assume.role.cli.OneloginAWSCLI.main(OneloginAWSCLI.java:331)
pitbulk commented 6 years ago

It seems an issue on the modifyProfiles method of the ProfilesConfigFileWriter. Is maybe a permission issue?

cornebester commented 6 years ago

Don't think so as it creates the .aws.bak. file and remove current .aws. Documentation is a bit vague, do I use path only or need to include credential file? e.g.-f "c:\scratch\.aws"

-f,--file Set a custom path to save the AWS credentials. (if not used, default AWS path is used)

pitbulk commented 6 years ago

If file is not provided, then the

AwsProfileFileLocationProvider.DEFAULT_CREDENTIALS_LOCATION_PROVIDER.getLocation();

is used at the method:

ProfilesConfigFileWriter.modifyOneProfile(file, profileName, new Profile(profileName, properties, null));

ProfilesConfigFileWriter class was implemented by AWS

Maybe you can enable the DEBUG and see what code failed.

cornebester commented 6 years ago

User error, I omitted file name. By specifying -f "custom path\credentials" this works.