EC2ResponseError:401 未授权使用 Saltstack boto_vpc 模块

EC2ResponseError:401 未授权使用 Saltstack boto_vpc 模块

我正在尝试使用 Saltstack 和 boto_vpc 模块创建一个 vpc。这是我的状态:

vpc_create:
  module.run:
    - name: boto_vpc.create
    - cidr_block: '10.0.0.0/24'
    - vpc_name: 'myVpc'
    - region: 'us-east-1'
    - key: 'ADJJDNEJFJGNFKFKFKIW'
    - keyid: 'SJDJNFNEJUWLLLCLCLENNRBFLGSLSLKEMFUHE'

我使用的键是正确的,但出现此错误:

[INFO    ] Running state [boto_vpc.create] at time 14:25:35.839797
[INFO    ] Executing state module.run for boto_vpc.create
[ERROR   ] 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>7cb74939-afda-4722-a31e-2855c5cbe16b</RequestID></Response>
[ERROR   ] {'ret': False}
[INFO    ] Completed state [boto_vpc.create] at time 14:25:35.882840
[DEBUG   ] File /var/cache/salt/minion/accumulator/49944656 does not exist, no need to cleanup.
[DEBUG   ] LazyLoaded highstate.output
[DEBUG   ] LazyLoaded nested.output
local:
----------
          ID: vpc_create
    Function: module.run
        Name: boto_vpc.create
      Result: False
     Comment: Module function boto_vpc.create executed
     Started: 14:25:35.839797
    Duration: 43.043 ms
     Changes:
              ----------
              ret:
                  False

Saltstack 版本:

Salt: 2015.5.0
         Python: 2.6.9 (unknown, Apr  1 2015, 18:16:00)
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: Not Installed

我尝试过aws ec2 create-vpc --cidr-block 10.0.0.0/16并且工作正常!

答案1

该错误表明您身份验证失败:

AWS was not able to validate the provided access credentials

仔细检查您的凭证(访问密钥/秘密访问密钥)

答案2

这里有几件事:

  1. 您应该使用 vpc 状态模块,因为它将幂等地执行操作:http://docs.saltstack.com/en/develop/ref/states/all/salt.states.boto_vpc.html#module-salt.states.boto_vpc
  2. 使用 key/keyid 可能存在一些错误。您不需要使用它。您可以在调用 salt 时使用 boto 的环境变量或 boto 的配置文件。请打开有关 key/keyid 问题的错误。

更新:似乎 2015.5 没有状态模块,这很不幸。不过,您可以将状态模块和更新的执行模块反向移植到 2015.5:http://ryandlane.com/blog/2015/06/03/using-development-branch-saltstack-python-modules-in-the-stable-release/

答案3

问题与按键有关。(我的错误,太愚蠢了)在这种情况下钥匙指的是AWS_SECRET_ACCESS_KEY密钥IDAWS_ACCESS_KEY_ID

相关内容