【问题标题】:I can connect to an AWS region but am not authorized to get the spot prices我可以连接到 AWS 区域,但无权获取现货价格
【发布时间】:2016-09-16 03:54:22
【问题描述】:

我正在尝试获取 AWS 现货价格历史记录,并从本教程中获得了帮助:https://medium.com/cloud-uprising/the-data-science-of-aws-spot-pricing-8bed655caed2#.nk3k2m1z0

当我取回连接对象时,我能够连接到给定的区域。

但是当我到达以下行时出现错误:

prices = ec2.get_spot_price_history(start_time=start, end_time=end, instance_type=instance)

这是我得到的错误:

will process from 2016-05-26T00:00:00 to 2016-05-26T11:59:59
EC2Connection:ec2.us-east-1.amazonaws.com
Traceback (most recent call last):
  File "test.py", line 30, in <module>
    prices = conn.get_spot_price_history(start_time=start, end_time=end, instance_type=instance_types[0])
  File "/usr/lib/python2.7/dist-packages/boto/ec2/connection.py", line 1420, in get_spot_price_history
    [('item', SpotPriceHistory)], verb='POST')
  File "/usr/lib/python2.7/dist-packages/boto/connection.py", line 1186, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>70a8b7bd-28e2-4526-83df-d0cb86e1f491</RequestID></Response>

谁能告诉我,我怎么可能连接但没有被授权?

【问题讨论】:

  • 创建连接不会执行任何网络请求或验证您的凭据。

标签: python amazon-web-services amazon-ec2 boto unauthorized


【解决方案1】:

我发现了问题所在。原来我的电脑时间慢了 7 分钟。我在某处读到 AWS 除了您的凭证之外还使用您的 CPU 时间。

基本上我手动更改了时间,现在可以了:)

【讨论】:

    【解决方案2】:

    您使用的 AWS 凭证无权执行 ec2:DescribeSpotPriceHistory 命令。

    解决这个问题:

    1. 转到 IAM 管理控制台
    2. 查找您在连接期间使用的 IAM 用户或角色
    3. 授予自己执行ec2:DescribeSpotPriceHistory的权限

    不要偷懒,给自己管理员权限。做对了,给自己正确的权限。

    【讨论】:

    • 我的用户拥有正确的权限。只是我的电脑时钟慢了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 2019-01-04
    • 1970-01-01
    • 2019-08-14
    • 2018-07-02
    • 2018-09-03
    相关资源
    最近更新 更多