awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.15k stars 770 forks source link

Profile is not picked up properly using aws-shell #166

Open seroandone opened 7 years ago

seroandone commented 7 years ago

I have two profiles in my .aws folder.

> cat config
[office]
output = json
region = us-east-1

[profile personal]
output = json
region = us-east-1

When I login to aws-shell I provide the profile

> aws-shell -p personal

Below is the output of '.profile'

aws> .profile
Current shell profile: personal

When I did 'ec2 describe-instances' it list all ec2's under my 'office' profile instead of 'personal'.

  1. I got a long list of ec2's for the below.

    aws> ec2 describe-instances
    {......}
  2. While below is the output if I specify --profile for 'ec2 describe-instances' command.

    aws> ec2 describe-instances --profile personal
    {
    "Reservations": []
    }

Since I set profile while entering aws-shell. I would expect both the above two cases (1 and 2) to return the same result i.e. the one returned by 2 (as it is correct). I would expect the same from 1 as well.

I am using aws-shell version (0.1.1)

donnemartin commented 7 years ago

Hi @seroandone, I'm not able to reproduce this issue on my system (macOS 10.12, Python 2.7.10) on a fresh install of aws-shell 0.1.1. Are you still seeing this issue and if so, consistently?

seroandone commented 7 years ago

Thanks @donnemartin I think i got the problem. I was having AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in my environment variables, so that took precedence over the profile I mentioned when i logged into aws-shell. Unfortunately some apps that I have needs this environment variables.

I would expect if i specifically provide -profile during login to aws-shell, I assumed it will use that instead of even the environment variable. Or at lease when i change to a profile while I am in the aws-shell. But this is ok if it is the way it is as well. So one must not have environment variable if they got to use the profile feature.

Thanks for looking into this.

donnemartin commented 7 years ago

If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are taking precedence over the profile feature (I haven't had a chance to verify this yet), I can see how that could be confusing. I'm not sure if that's the intended behavior. Thanks for the additional information!

rdrey commented 7 years ago

Suggestion: This would have probably been easier to debug if .profile also output the currently selected access key

markl-vesper commented 5 years ago

I've just downloaded both awscli & aws-shell (Windows 10)

Profiles work fine in cli and I get correct json output from ec2 describe-hosts command after setting profile using set AWS_PROFILE=xxxxxxxxx

However when I start aws-shell and provide same profile name ie aws-shell -p xxxxxxxxx and run same command I am not authorised to perform the operation.

Same issue I think