当使用AWS CLI(命令行界面)时,可能会遇到保存AWS profile失败的情况,这是由于AWS CLI未能正确配置credentials file。在Linux和Mac操作系统上,credentials file的路径为~/.aws/credentials,而在Windows上则是%UserProfile%.aws\credentials。为了解决这个问题,可以手动在credentials file中加入以下代码,其中myprofile即为要保存的AWS profile名称:
[myprofile]
aws_access_key_id=your_access_key
aws_secret_access_key=your_secret_key
如果还是无法保存AWS profile,可以尝试使用以下命令:
aws configure --profile myprofile
该命令将自动创建一个名为myprofile的AWS profile,并设置访问密钥和密钥。如果AWS profile保存成功,可以通过以下命令查看:
aws configure list-profiles
提示:access key和secret key可以在AWS Console中的IAM服务下的用户页面中获取。