python - Serverless 在 Conda 虚拟环境中找不到我的 AWS 凭证是否有原因?
问题描述
我正在尝试使用无服务器框架将 lambda 函数部署到 AWS。一切似乎都运行良好,但是当我运行任一命令进行部署sudo sls deploy
或sudo serverless deploy
出现以下错误时。
我知道错误消息指出找不到我的 AWS 凭证,但我不确定为什么?
我已经根据http://slss.io/aws-creds-setup上的文档使用无服务器配置凭据进行了设置
我已采取以下措施来解决此问题:
- 重新运行
serverless config credentials --provider aws --key key --secret secret
- 尝试将
Profile:
“默认”和 AWS 中的用户名添加到我的 YAML 文件中。 - 使用 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
解决方案
尝试在您的 conda 环境中运行 aws configure:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html
另外,请不要使用 sudo 运行它,如果您需要这样做,您可能安装了不正确的东西。
推荐阅读
- python - 在 Python 中创建条件
- clojure - 合并同一集合的功能
- ios - 如何仅在 Apple Watch 应用程序中打开网页链接?
- linq - 为子属性创建 MethodCallExpression
- django - 自定义用户模型的 Wagtail 迁移错误
- android - 无法更改 MutableList 中的对象属性
- woocommerce - 自定义产品类型在更新时不更改类型
- android - 在 Android 10 中以更“通用”的方式断开与 Wi-Fi 网络的连接
- laravel - 使用 Laravel 在嵌套路由中调用 2 次 VueJS 组件
- java - 为什么“addOnSuccessListener”的代码在以下代码块中的执行过程中会被跳过?