首页 > 解决方案 > Serverless 在 Conda 虚拟环境中找不到我的 AWS 凭证是否有原因?

问题描述

我正在尝试使用无服务器框架将 lambda 函数部署到 AWS。一切似乎都运行良好,但是当我运行任一命令进行部署sudo sls deploysudo serverless deploy出现以下错误时。

我知道错误消息指出找不到我的 AWS 凭证,但我不确定为什么?

我已经根据http://slss.io/aws-creds-setup上的文档使用无服务器配置凭据进行了设置

我已采取以下措施来解决此问题:

  1. 重新运行serverless config credentials --provider aws --key key --secret secret
  2. 尝试将Profile:“默认”和 AWS 中的用户名添加到我的 YAML 文件中。
  3. 使用 export AWS_ACCESS_KEY_ID=export AWS_SECRET_ACCESS_KEY= 在我的环境中设置凭证。

我注意到我的.aws/credentials文件存在,但它不在我的虚拟环境中。我假设因为这个无服务器无法找到凭据,但我没有在任何地方看到这个记录。

我错过了什么吗?

[sudo] password for osboxes: 
Serverless: Generated requirements from /home/osboxes/spacy-med/requirements.txt in /home/osboxes/spacy-med/.serverless/requirements.txt...
Serverless: Installing requirements from /home/osboxes/spacy-med/.serverless/requirements/requirements.txt ...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
 
 Serverless Error ----------------------------------------
 
  AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: <http://slss.io/aws-creds-setup>.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.17.4
     Framework Version:         2.53.1
     Plugin Version:            5.4.3
     SDK Version:               4.2.6
     Components Version:        3.14.2```


  [1]: https://www.serverless.com/framework/docs/providers/aws/guide/credentials#setup-with-serverless-config-credentials-command

标签: pythonamazon-web-servicesaws-lambdayamlserverless-framework

解决方案


尝试在您的 conda 环境中运行 aws configure:

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html

另外,请不要使用 sudo 运行它,如果您需要这样做,您可能安装了不正确的东西。


推荐阅读