[英]Amazon Web Services: NoCredentialsError: Unable to locate credentials
I am using amazon web services cli. 我正在使用亚马逊网络服务CLI。 I use a makefile to to build my lambda project and upload it to aws lambda.
我使用makefile来构建我的lambda项目,并将其上传到aws lambda。 I am on a windows machine and using powershell to call make.
我在Windows计算机上,使用Powershell调用make。
I try to delete my lambda function with the following lines 我尝试使用以下几行删除我的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
I get this error.. 我收到此错误。
NoCredentialsError: Unable to locate credentials Unable to locate credentials. NoCredentialsError:无法找到凭据无法找到凭据。 You can configure credentials by running "aws configure".
您可以通过运行“ aws configure”来配置凭据。
Running aws configure list prints out a valid default profile. 运行aws configure列表会打印出有效的默认配置文件。
I think the problem is because i am using gnu make installed by cygwin on a windows machine. 我认为问题是因为我正在使用Windows机器上cygwin安装的gnu make。 Using powershell to call make.
使用powershell调用make。
So the path to credentials looks like this "cygdrive/c/users/testbox/.aws/credentials" instead "c:\\users\\testbox.aws\\credentials", when ~/.aws/credentials is evaluated by aws. 因此,当〜/ .aws / credentials由aws评估时,凭据的路径看起来像这样的“ cygdrive / c / users / testbox / .aws / credentials”而不是“ c:\\ users \\ testbox.aws \\ credentials”。 I think :)
我认为 :)
I had the same problem with the path to aws itself and had to use $(shell cygpath -aw ${AWS_PATH}) to convert it to a path windows python could use. 我在aws本身的路径上也遇到了同样的问题,不得不使用$(shell cygpath -aw $ {AWS_PATH})将其转换为Windows python可以使用的路径。
Is there any way to pass the credentials directly to the lambda delete-function or indirectly through a path to a file? 有什么方法可以将凭据直接传递给lambda delete-function或通过文件路径间接传递? I cant seem to think of a way because the code that searches for the credentials is internal to botocore.
我似乎无法想到一种方法,因为搜索凭据的代码是botocore的内部代码。
Is there a way around this that you know off? 有没有解决的办法可以解决?
Alternative solution, consider using AWS SAM templates 替代解决方案,请考虑使用AWS SAM模板
Use AWS SAM templates to deploy your Lambda functions and AWS resources using CloudFormation. 使用AWS SAM模板通过CloudFormation部署Lambda函数和AWS资源。
aws cloudformation package
to package and upload your local code to S3. aws cloudformation package
以打包并将您的本地代码上传到S3。 aws cloudformation deploy
to provision and update AWS resources with the updated code on S3. aws cloudformation deploy
以使用S3上的更新代码来配置和更新AWS资源。 This would work in CMD/Powershell without the make
hassle. 这将在CMD / Powershell中正常工作,而不会
make
麻烦。 You will also have the benefit of having your resources versioned as code and you won't need to worry about tracking or adding new AWS APIs in your make file. 您还将受益于将资源版本化为代码,并且不必担心在make文件中跟踪或添加新的AWS API。
More complex serverless frameworks for reference: 更复杂的无服务器框架供参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.