So I have a private s3 bucket and want to be able to upload a file to it.
My user has a AmazonS3FullAccess and turns out it's not enough.
The error is
Error executing "PutObject" on "https://my-existing-bucket-name.s3.amazonaws.com/5037f466f9018271b16b1e77d3d7f386.pdf"; AWS HTTP error: Client error: `PUT https://my-existing-bucket-name.s3.amazonaws.com/5037f466f9018271b16b1e77d3d7f386.pdf` resulted in a `403 Forbidden`
I also tried to add a custom policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::my-existing-bucket-name/*"
}
]
}
but still it doesn't work, while it is possible to delete or retrieve a file using same credentials.
Here is how I'm uploading files to AWS (it works fine if to switch bucket access from private to public)
$this->s3Client->putObject([
'Bucket' => $this->bucket,
'Key' => $keyName,
'ContentType' => $contentType,
'CacheControl' => 'max-age=86400',
'Body' => fopen($file, 'rb'),
'ACL' => 'authenticated-read',
]);
$this->s3Client->putObjectexecute under your IAM user, or some IAM role? - MarcinBlock all public accessand all the checkboxes below to On - Lunin Roman