Due to failings within SSIS and losing patience I thought of using php as a go between to help move and retrieve files from the AMAZON S3 bucket.
Theres an access issue that we cant seem to get round
Steps so far
WE use IIS
The Amazon PHP SDK was downloaded
user C:\inetpub\wwwroot\phpaws
a index.php
file was created
the code
/error_reporting(E_ERROR);
require './aws/aws-autoloader.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$bucket = 'BUCKET';
$keyname = 'RKPHPTest.txt';
$filepath = './RKPHPTest.txt';
// Instantiate the client.
$s3 = S3Client::factory(array(
'key' => 'NAME',
'secret' => 'NAME',
'region' => 'eu-west-1',
'version' => 'latest',
'ssl.certificate_authority' => 'C:\inetpub\wwwroot\phpaws\cacert.pem'
));
try {
// Download data.
$result = $s3->getObject(array(
'Bucket' => $bucket,
'Key' => "NAME.txt"
));
// Print the object.
echo $result;
} catch (S3Exception $e) {
echo $e->getMessage() . "
";
}
echo "<br><br>";
try {
// Upload data.
$result = $s3->putObject(array(
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => $filepath,
'ACL' => 'public-read'
));
// Print the URL to the object.
echo $result['ObjectURL'] . "
";
} catch (S3Exception $e) {
echo $e->getMessage() . "
";
}
Then when the API is ran we get on both post and get error msg
Error executing "GetObject" AWS HTTP error: Client error: 403 AccessDenied (client): Access Denied - AccessDeniedAccess
the permissions on account are as follows:
{
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::BUCKET*"
},
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
}
]
}
Which means we can do all commands any suggestions on how to get around this error would be great?
Many thanks
Robert
TO be clear
This is the full permissions listed
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::BUCKET/*"
},
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::BUCKET"
}
]
}ShowPolicy{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "importexport:*",
"Resource": "*"
}
]
}