2

当我登录我的 awseducate 帐户并单击帐户详细信息时,我会获得我的凭据。 查看帐户生成的凭据

我成功地将这些凭证与我的 S3 存储桶一起使用来上传和下载文件。但是,当我尝试将这些凭据与弹性 beanstalk 服务 - ebcli ( eb init命令) 一起使用时,我收到消息ERROR: NotAuthorizedError - Operation Denied。请求中包含的安全令牌无效。

F:\cloud-developer-master\course-02\project\image-filter-starter-code>eb init

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
...
(default is 3): 1
You have not yet set up your credentials or your credentials are incorrect
You must provide your credentials.
(aws-access-id): ASIxxxxxxxxxxxxxxxxxxxxxxxx
(aws-secret-key): hVCExxxxxxxxxxxxxxxxxxxxxxx
ERROR: NotAuthorizedError - Operation Denied. The security token included in the request is invalid.

任何线索为什么这些不被接受?

注意:我无法使用新用户创建新凭据,因为此 AWS 学生账户不允许此操作。我尝试引用页面以获取新凭据,但仍然没有成功。

我尝试创建.aws/credentials文件并复制并粘贴这些凭据,但仍未被接受:

F:\cloud-developer-master\course-02\project\image-filter-starter-code>eb init

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
...
(default is 3): 1
ERROR: The current user does not have the correct permissions. Reason: Operation Denied. The security token included in the request is invalid.
ERROR: The current user does not have the correct permissions. Reason: Operation Denied. The security token included in the request is invalid.
You have not yet set up your credentials or your credentials are incorrect
You must provide your credentials.
(aws-access-id): ASIxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(aws-secret-key): 1Ssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ERROR: NotAuthorizedError - Operation Denied. The security token included in the request is invalid.
4

2 回答 2

2

感谢一个使用伪Gambit-的人,我找到了解决问题的方法(详情请点击此处)。您必须在文件夹中创建两个文件:C:\Users\YOURUSERNAME\.aws

配置

[default] 
region = us-east-1 # replace this with your region (don't select it in the CLI) 
output = json

证书

[default]
aws_access_key_id=REPLACE_WITH_YOUR_ACCESS_KEY
aws_secret_access_key=REPLACE_WITH_YOUR_SECRET_KEY
aws_session_token=REPLACE_WITH_YOUR_TOKEN

一点解释:当您在 cmd 中选择区域时,eb-cli 将通过生成和存储一个名为[eb cli]的新配置文件来自动更新配置文件,该配置文件将填充您在 cmd 中选择的信息。但是,我确实将配置文件[default]放在了两个不同配置文件的文件凭据中。因此,身份验证失败。

另外,感谢约翰·罗滕斯坦的帮助

于 2019-11-22T08:04:02.423 回答
1

AWS Educate 为您提供在一段时间后过期的临时凭证。它们是通过 AWS 安全令牌服务 (STS) 生成的。

临时凭证包括:

  • 访问密钥
  • 密钥
  • 会话令牌

您显示的eb init脚本仅要求前两项,而不是Session Token。没有会话令牌,凭据无效。

用这种方法也许可以克服:

  • Run aws configure,它将要求您提供凭据,然后将它们存储在~.aws/credentials其中(包括安全令牌)
  • Run eb init,它应该使用该文件中的凭据

aws configure --profile foo最坏的情况,通过然后使用替代配置文件eb init --profile foo

于 2019-11-16T06:47:42.777 回答