When working with certain third-party tools like Terraform, it's not easily possible to specify an AWS CLI profile, and I like working with the environment variables better than the profiles.
Is there a way for me to have the AWS CLI simply export the current profile as AWS_ACCESS_KEY_ID
and AWS_SECRET_KEY
environment variables to my session?
you could use the following command to set your environment variable
aws configure get default.aws_access_key_id
aws configure get default.aws_secret_access_key
if you have another profile you can change, another way to write is
aws configure get aws_access_key_id --profile <new_profile>
aws configure get aws_secret_access_key --profile <new_profile>
so for example it would be
export TF_VAR_access_key=`aws configure get default.aws_access_key_id`