AWS Iam commands that work correctly in the terminal and do not work in the Laravel / PHP AWS SDK

I use OS: Ubuntu 14.04 and installed the AWSCLI package using the terminal. when executing AWS Iam commands, its work is excellent.

for example: I ran this command aws iam list-users and got the following results

{
    "Users": [
        {
            "Arn": "arn:aws:iam::3**16****332:user/xyz",
            "CreateDate": "2014-09-29T14:21:25Z",
            "UserId": "AIDAJY*******MW**W",
            "Path": "/",
            "UserName": "xyz"
        },
        {
            "Arn": "arn:aws:iam::34****044**2:user/abcxyz",
            "CreateDate": "2014-02-07T21:08:53Z",
            "UserId": "AIDAJ******JML**V6Y",
            "Path": "/",
            "UserName": "abcxyz"
        },
}

When using the AWS SDK with Laravel 5.1, I configure Key, Secrect, Region, etc. (same as in AWSCLI package )

when running this code in Laravel 5.1

$Iam    =   \App::make('aws')->createClient('Iam');
$result =   $Iam->listUsers();

echo "<pre>";
  print_r($result);
die();

get the following error (see attachment). enter image description here

which may be the reason, because the same configuration works fine in the terminal, but not with the SDK. I also tried SQS, which works fine in the following code.

$obj    =   \App::make('aws')->createClient('Sqs');
$queue  =   $obj->getQueueUrl(['QueueName'=>'sms-demo']);
$queueUrl=   $queue->get('QueueUrl');

$result = $obj->receiveMessage(
                array('QueueUrl'=> $queueUrl));
+4
1

IAM - , . api us-east-1 .

+4

Source: https://habr.com/ru/post/1625278/


All Articles