boltops-tools / aws-mfa-secure

AWS MFA Secure Session for CLI and SDK
MIT License
23 stars 5 forks source link

commands do not work with `--profile` different from the default one #8

Open pyrocks opened 2 years ago

pyrocks commented 2 years ago

Hi,

I was having difficulties making the wrapper work while specifying a different profile using the --profile flag the following commands were all issued in quick succession

~/somefolder > which aws
aws: aliased to aws-mfa-secure session

no profile - working - I already entered my mfa token earlier today, default profile is not profile123:

~/somefolder > aws s3 ls s3://some-bucket-name/
<list of files returned>

with --profile - not working

~/somefolder > aws --profile profile123 s3 ls s3://some-bucket-name/

An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied

export AWS_PROFILE instead of --profile - now it's working - notice requesting the MFA code which --profile didn't

~/somefolder > export AWS_PROFILE=profile123
~/somefolder > aws s3 ls s3://some-bucket-name/
Please provide your MFA code: <code entered>
<list of files returned>

even after doing this - --profile still doesn't work and I get the same error.