S3 access in Laravel 403 Forbidden error
When I wrote the following code in Larael
Storage :: disk ('s3')-> put ('hoge.csv','Ai');
Error executing "PutObject" on "https://bucket-name.s3.ap-northeast-1.amazonaws.com/hoge.csv"; AWS HTTP error: Client error: `PUT https://bucket-name.s3 .ap-northeast-1.amazonaws.com/hoge.csv` resulted in a `403 Forbidden` response: ...
Error was displayed.
Since the authority setting of S3 is done in config / filesystems.php
, when looking at the corresponding file, confirm that the secret access key is incorrect. Correct and re-execute. But I keep getting the exact same error.
There was no problem even if I reviewed the bucket policy and IAM settings, and when I tried PutObject from aws cli, it seemed that the permissions were set because it worked.
Caused by cache
The cause is Laravel’s cache setting
php artisan cache: clear
php artisan config: clear
php artisan config: cache
After clearing Larael’s cache by executing the above command, PutObject can be created without any problem (probably one of the commands is fine, but it has not been verified). It seemed like I was getting an error forever because I cached what I accidentally set the secret access key in the beginning.