When an AWS account is set up to use AWS IAM Identity Center it's common to have SSO integration. The CLI then uses temporary credentials to access the AWS account that need to be refreshed on a regular basis. This is normally done with the command aws sso login which launches the default browser for the user to authorize the CLI to access the account. If you want to use a non-standard Chrome profile for AWS this is how.
You need a shell script to launch Chrome with the correct profile. Here is an example script that you can use:
#!/bin/bash
# This script is needed because you don't seem to be able to use the command with arguments with the `BROWSER` environmental
# variable. So this script adds the arguments.
# Set this to the name of the profile directory you want to use.
# The profile directory is located in `~/Library/Application Support/Google/Chrome/`
profile="Profile XXXX"
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --profile-directory="${profile}" $*I put this script a file called aws-login.sh in my ~/bin directory and made it executable with chmod +x ~/bin/aws-login.sh.
To get the aws command to use this script when it needs to launch a web browser set the BROWSER environmental variable. I did this by adding an alias to the end of my .bashrc file:
alias aws='BROWSER=~/bin/aws-login.sh aws'Just run aws sso login and the script will launch Chrome with the correct profile.