The config profile (adminuser) could not be found

I have an IAM user adminuser which is in the Administrators group (having AdministratorAccess).

I have used aws configure to set up the settings.

~/.aws/config

[default]
region = us-east-1
output = json

~/.aws/credentials

[default]
aws_access_key_id = ************
aws_secret_access_key = ************

But when I run aws lambda list-functions --profile adminuser, it says

The config profile (adminuser) could not be found

Once I run export AWS_DEFAULT_PROFILE=adminuser, and run aws lambda list-functions --profile adminuser again, it shows:

botocore.exceptions.ProfileNotFound: The config profile (adminuser) could not be found

I read AWS CLI Config profile not found. So I try to changed to

~/.aws/config

[adminuser]
region = us-east-1
output = json

~/.aws/credentials

[adminuser]
aws_access_key_id = ************
aws_secret_access_key = ************

and run aws lambda list-functions --profile adminuser again, then it shows:

You must specify a region. You can also configure your region by running "aws configure".

I also tried this like the official AWS document demo

~/.aws/config

[default]
region = us-east-1
output = json

[adminuser]
region = us-east-1
output = json

~/.aws/credentials

[default]
aws_access_key_id = ************
aws_secret_access_key = ************

[profile adminuser]
aws_access_key_id = ************
aws_secret_access_key = ************

But still failed.

How can I run aws lambda list-functions --profile adminuser successfully? Thanks


I finally succeed by using

~/.aws/config

[default]
region = us-east-1
output = json

~/.aws/credentials

[adminuser]          // <- here changes to adminuser
aws_access_key_id = ************
aws_secret_access_key = ************
region = us-east-1   // <- note this line

Instead of using aws lambda list-functions --profile adminuser you can use aws lambda list-functions --profile default

and it will be done.

OR you may like to change "default" to "adminuser", that you have done.

This is not like the documentation is incorrect or something like that.