Ad

AWS Iam Commands, Working Correct In Terminal And Not Working In Laravel/PHP AWS SDK

I am using OS: Ubuntu 14.04 and installed AWSCLI package using terminal. while running AWS Iam commands, its working fine.

eg: I ran this command aws iam list-users and got 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"
        },
}

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

while running this code in Laravel 5.1

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

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

getting following error(see attachment). enter image description eferrerenter image description here

what can be reason because same configuration working fine in terminal but not with SDK. I also tried SQS, which is working fine see following code.

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

$result = $obj->receiveMessage(
                array('QueueUrl'=> $queueUrl));
Ad

Answer

IAM is a global service and not region specific. However when using the api you must use the us-east-1 region for the call.

Ad
source: stackoverflow.com
Ad