How To Fix aws Command Error “You must specify a region”

I was getting error “You must specify a region” when running any aws CLI command. The fix: Using the aws command:
1 |
aws configure set region us-east-1 --profile demo |
which will automatically add the following to the file ~/.aws/config:
1 2 |
[profile demo] region = us-east-1 |
You many simply edit the ~/.aws/config file yourself and append the same thing:
1 2 3 4 |
vi ~/.aws/config [profile demo] region = us-east-1 |