0
votes

I am trying to get my assets stored in S3 by calling a API implemented as Lambda function using Bref Serverless Package. I am using Laravel. A call to Storage::directories(); give the following error.

message: Error executing "ListObjects" on "https://calmed-storage.s3.us-west-2.amazonaws.com/?prefix=&delimiter=%2F&encoding-type=url"; AWS HTTP error: Client error: GET https://mys3-storage.s3.us-west-2.amazonaws.com/?prefix=&delimiter=%2F&encoding-type=url resulted in a 403 Forbidden response: The AWS Access Key Id you provided (truncated...) InvalidAccessKeyId (client): The AWS Access Key Id you provided does not exist in our records. - InvalidAccessKeyIdThe AWS Access Key Id you provided does not exist in our records.

2

2 Answers

0
votes

Well the error says it all, you need to send a correct AWS key when communicating with their API.

if you use league/flysystem-aws-s3-v3 as described in the official Laravel docs then you need to set the AWS S3 environment variables listed below in your .env file

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_URL=

To get an access key you need to create a user with correct access permissions is Amazon. This tutorial will help you with that.

0
votes

I was using Laravel and credentials were stored in .env file. aws-sdk-php was somehow changing the Access ID and Secret Key. I don't know why. The issue was solved when I hard coded Access ID and Secret Key in filesystems.php.