amazon-web-services - 亚马逊网络服务 : NoCredentialsError: Unable to locate credentials

标签 amazon-web-services makefile cygwin aws-lambda

我正在使用亚马逊网络服务 cli。我使用 makefile 来构建我的 lambda 项目并将其上传到 aws lambda。我在 Windows 机器上并使用 powershell 调用 make。

我尝试使用以下几行删除我的 lambda 函数

AWS_PATH = /cygdrive/c/Users/TestBox/AppData/Roaming/Python/Scripts/aws
AWS_WIN_PATH = $(shell cygpath -aw ${AWS_PATH})
AWS_REGION = eu-west-2

lambda_delete:
    $(AWS_WIN_PATH) lambda delete-function --function-name LambdaTest --region $(AWS_REGION) --debug

我收到此错误..

NoCredentialsError:无法找到凭据 无法找到凭据。您可以通过运行“aws configure”来配置凭证。

运行 aws configure list 会打印出有效的默认配置文件。

我认为问题是因为我在 Windows 机器上使用 cygwin 安装的 gnu make。使用powershell调用make。

因此,当 aws 评估 ~/.aws/credentials 时,凭证的路径看起来像“cygdrive/c/users/testbox/.aws/credentials”而不是“c:\users\testbox.aws\credentials” 。我想:)

我对 aws 本身的路径也有同样的问题,必须使用 $(shell cygpath -aw ${AWS_PATH}) 将其转换为 Windows python 可以使用的路径。

是否有任何方法可以将凭据直接传递到 lambda 删除函数或通过文件路径间接传递?我似乎想不出办法,因为搜索凭据的代码是 botocore 的内部代码。

您知道有解决这个问题的方法吗?

最佳答案

替代解决方案,考虑使用AWS SAM templates

使用 AWS SAM 模板通过 CloudFormation 部署您的 Lambda 函数和 AWS 资源。

  • 编辑您的 SAM 模板并定义您的 AWS 资源。例如,定义代码的 Lambda 函数/路径。
  • aws cloudformation package 用于打包本地代码并将其上传到 S3。
  • aws cloudformation 部署,使用 S3 上的更新代码配置和更新 AWS 资源。

这可以在 CMD/Powershell 中工作,而无需 make 麻烦。您还可以享受将资源版本化为代码的好处,并且无需担心在 make 文件中跟踪或添加新的 AWS API。

更复杂的无服务器框架供引用:

关于amazon-web-services - 亚马逊网络服务 : NoCredentialsError: Unable to locate credentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46635545/

相关文章:

amazon-web-services - Freenom.com 和 AWS Amplify : Amazon asks me to 'configure root domain' (@ ANAME abc-whatever-xyz. cloudfront.net) -> Freenom:不允许使用通配符

database - AWS EC2 和 Redshift 安全组连接错误

C Makefile 链接器错误 -

python - 对 `scons -c` 执行自定义操作

linux - lpr 命令不适用于 CYGWIN。

tomcat - Hudson "stop"/取消构建留下进程

amazon-web-services - AWS机器学习通过三个字段进行预测

git - 我如何告诉我所有的 AWS EC2 实例从 git/codecommit 中提取?

c++ - VPATH 中的递归搜索?

c++ - boost::asio::acceptor 在 win7 上挂起