Adding these scripts will give you the following aliases on your command line.
Note: the scripts are only tested on OSX
awsall- Lists all available AWS profiles. Note that the list is based on the.aws/credentialsfile.awswho- Lets you know what profile you are currently usingawssso profilename- Quickly signin using AWS IAM Identity Center. (Recommended)- Note: This will attempt open a browser window for sign-in confirmation.
awsp profilename- Similar to awssso but for use with IAM Users and IAM Assume Role
- Create
~/.aws/alises.shand copy the contents of the snippet. - Update
~/.bash_profile(or equivalent file) with the contents of that snippet - Ensure that you configure the AWS CLI using
~/.aws/configand~/.aws/credentials. See examples.
As an added bonus there are also examples for how to easily authenticate with Code Artifact.
Note:
awssso and awsp adds a non-standard environment variable named AWS_ACCOUNT which contains the AWS Account Id.