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
~/.aws/credentials
Instead of using
aws lambda list-functions --profile adminuser
you can useaws 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.
I faced the same issue with Jenkins on windows, I copied .aws folder from my profile to system profile
C:\Windows\System32\config\systemprofile\
without changing Jenkins service i.e. Jenkins service runs on local system account. Then windows batch jobs on Jenkins fetches the same results as if we run in windows cmd. Moreover, I uninstalled the AWSCLI done by the pip3 method, used AWSCLI .msi type installation, hence resolved PATH issue error ( "aws command not found" during build)If you are using jenkins in windows please change log on user in windows service configuration. Restart the service. Should work.
I was facing same issue, In my case config and credential files were not having read access. provided access chmod 755 for both files and issue resolved.