There used to be no way , but now there is.
I wrote a script for this aws-env:
usage: aws-env [-h] [-n] profile
Extract AWS credentials for a given profile as environment variables.
positional arguments:
profile The profile in ~/.aws/credentials to extract credentials
for.
optional arguments:
-h, --help show this help message and exit
-n, --no-export Do not use export on the variables.
If you trust the output of this program, you can use it in your shell session to export variables of this profile:
$ aws-env profile-name
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
$ aws-env -n profile-name
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
, ( , , ;]):
$ echo $AWS_ACCESS_KEY_ID
$ $(aws-env profile-name)
$ echo $AWS_ACCESS_KEY_ID
AKJHC...