To setup a new credential profile with the name myprofile:
$ aws configure --profile myprofile AWS Access Key ID [None]: ACCESSKEY AWS Secret Access Key [None]: SECRETKEY Default region name [None]: REGIONNAME Default output format [None]: text | table | json
For the AWS access key id and secret, create an IAM user in the AWS console and generate keys for it.
Region will be the default region for commands in the format eu-west-1 or us-east-1.
The default output format can either be text, table or json.
You can now use the profile name in other commands by using the --profile option, e.g.:
$ aws ec2 describe-instances --profile myprofile
AWS libraries for other languages (e.g. aws-sdk for Ruby or boto3 for Python) have options to use the profile you create with this method too. E.g. creating a new session in boto3 can be done like this, boto3.Session(profile_name:'myprofile') and it will use the credentials you created for the profile.
The details of your aws-cli configuration can be found in ~/.aws/config and ~/.aws/credentials (on linux and mac-os). These details can be edited manually from there.