-solved-
I am very new to using AWS and this is definitely a novice question, but I've been stuck on this for sometime now and I haven't been able to find an answer.
I am running an EC2 instance with a IAM role that has the AmazonS3FullAccess policy attached. I am attempting to run the following PHP code:
<?php
echo '<br>loaded file<br>';
// SDK downloaded as ZIP file
require_once('SDK/aws-autoloader.php');
echo '<br>loaded sdk<br>';
use Aws\Exception\AwsException;
use Aws\S3\Exception\S3Exception;
// Use the us-east-1 region and latest version of each client.
$SharedConfig =
[
'region' => 'us-east-1',
'version' => 'latest'
];
// Create an SDK class used to share configuration across clients.
$SDK = new Aws\Sdk($SharedConfig);
echo '<br>created sdk object<br>';
// Create an Amazon clients using the shared configuration data.
$S3Client = $SDK->createS3();
echo '<br>created s3 client<br>';
$RDSClient = $SDK->createRds();
echo '<br>created rds client<br>';
$Buckets = $S3Client->listBuckets();
echo '<br>bucket list<br>';
var_dump($Buckets);
echo '<br>end of list<br>';
Accessing the page outputted the following:
loaded file
loaded sdk
created sdk object
created s3 client
created rds client
which implies nothing after "$Buckets = $S3Client->listBuckets();" was executed.
I would like to ask the following:
What is the correct way to call listBuckets() using a PHP script ran by an EC2 instance configured through IAM roles?
Assuming SDK functions generate error messages and/or exceptions, how do I view these error messages and/or exceptions?
Thanks in advance.