简体   繁体   English

亚马逊网络服务:NoCredentialsError:无法找到凭证

[英]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资源。

  • Edit your SAM template and define your AWS resources. 编辑您的SAM模板并定义您的AWS资源。 For example, define Lambda functions/path to your code. 例如,定义代码的Lambda函数/路径。
  • 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 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.

相关问题 AWS - NoCredentialsError:无法找到凭证 - AWS - NoCredentialsError: Unable to locate credentials botocore.exceptions.NoCredentialsError:无法找到凭据 - botocore.exceptions.NoCredentialsError: Unable to locate credentials AWS CloudWatch 代理:NoCredentialsError:无法找到凭证 - AWS CloudWatch Agent: NoCredentialsError: Unable to locate credentials 包装工| Ansible | NoCredentialsError:无法找到凭据 - Packer | Ansible | NoCredentialsError: Unable to locate credentials NoCredentialsError botocore.exceptions.NoCredentialsError:即使在传递凭据后也无法找到凭据 - NoCredentialsError botocore.exceptions.NoCredentialsError: Unable to locate credentials even after passing credentials 如何解决 botocore.exceptions.NoCredentialsError:无法找到凭据 - How to solve botocore.exceptions.NoCredentialsError: Unable to locate credentials botocore.exceptions.NoCredentialsError:无法在 AWS ECS 中找到凭证 - botocore.exceptions.NoCredentialsError: Unable to locate credentials in AWS ECS 以用户身份使用 Python 登录 Cognito AWS - NoCredentialsError:无法找到凭证 - Cognito AWS login with Python as a user - NoCredentialsError: Unable to locate credentials botocore.exceptions.NoCredentialsError:无法找到凭据 - Github 操作 - botocore.exceptions.NoCredentialsError: Unable to locate credentials - Github Actions NoCredentialsError:无法找到凭据 - python 模块 boto3 - NoCredentialsError : Unable to locate credentials - python module boto3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM