【问题标题】:AWS - You are not authorized to perform this operation on accessing describeInstanceStatus from ec2 client objectAWS - 您无权在从 ec2 客户端对象访问 describeInstanceStatus 时执行此操作
【发布时间】:2014-04-25 09:24:38
【问题描述】:

我使用 AWS 文档中提到的方法创建了一个 ec2 客户端。我正在为 SDK 使用 aws.phar 文件。 ec2 客户端创建正确,因为当我var_dump 客户端时,它返回 Ec2Client 对象。但是当我尝试从 ec2 客户端访问 describeInstanceStatus 时,它会引发 You are not authorized to perform this operation. 异常。这是我的代码。

use Aws\Ec2\Ec2Client;
require 'aws.phar';

$ec2Client = Ec2Client::factory(array(
'key'    => '<aws access key>',
'secret' => '<aws secret key>',
'region' => 'us-east-1'
));

try{
$ec2Client->describeInstanceStatus(array(
    'DryRun' => false,
    'InstanceIds' => array('InstanceId'),
    'Filters' => array(
        array(
            'Name' => 'availability-zone',
            'Values' => array('us-east-1'),
        ),
    ),
    'MaxResults' => 10,
    'IncludeAllInstances' => false,
));}
catch(Exception $e){
echo $e->getMessage();
}

请告诉我我哪里弄错了。我试过用谷歌搜索它,查看 AWS 论坛但没有结果。谢谢你。

【问题讨论】:

    标签: php amazon-web-services amazon-ec2


    【解决方案1】:

    错误来自您已通过 AWS IAM 授予/拒绝的访问权限。

    您在代码中使用其访问/密钥的用户没有描述实例的权限。此权限在应用于此用户的 IAM 策略中配置。

    您的代码没有任何问题。您需要查看 IAM 政策,了解授予/拒绝此用户的所有权限。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-12
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 2021-09-30
      • 1970-01-01
      相关资源
      最近更新 更多