Reputation: 1164
I'm getting an AccessDeniedException
from the AWS PHP SDK when I try to put an object into an S3 bucket using Laravel. I've configured the key, secret and region in application/config/packages/aws/aws-sdk-php-laravel/config.php
. I then try to execute a simple putObject using the following code:
try {
AWS::get('s3')->putObject(array(
'Bucket' => Config::get('settings.AWS_BUCKET'),
'Key' => 'hello_.txt',
'Body' => 'hi',
'ACL' => 'public-read'
));
return 'great success';
} catch (Exception $e) {
return $e;
}
Which, as you may expect by my asking this question to begin with, fails and returns something like this (with the request ID changing each time):
Aws\S3\Exception\AccessDeniedException: AWS Error Code: AccessDenied, Status Code: 403, AWS Request ID: CA0E8181A5F2D740, AWS Error Type: client, AWS Error Message: Access Denied, User-Agent: aws-sdk-php2/2.7.20 Guzzle/3.9.2 curl/7.40.0 PHP/5.4.37 Laravel/4.2.17 L4MOD/1.1.0
From what I can tell I'm only being denied access to the bucket. If I alter the key or secret I get a InvalidAccessKeyIdException
and SignatureDoesNotMatchException
respectively. What am I missing here?
Upvotes: 2
Views: 4278
Reputation: 1164
I finally found that if I added the AmazonS3FullAccess policy under the user's permission under IAM the application finally worked and I was able to create and upload items to the bucket.
Upvotes: 9