'Laravel aws lambda file upload exception - Aws\S3\Exception\S3Exception: Error executing InvalidAccessKeyId

Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://sage-dev-serverlessdeploymentbucket-1t0g1w1stv04r.s3.amazonaws.com/images/background.jpg" AWS HTTP error: Client error: `PUT https://sage-dev-serverlessdeploymentbucket-1t0g1w1stv04r.s3.amazonaws.com/images/background.jpg` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided (truncated...)
 InvalidAccessKeyId (client): The AWS Access Key Id you provided does not exist in our records. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.


Solution 1:[1]

Make sure you correctly added the token in the s3 configuration in database:

https://bref.sh/docs/frameworks/laravel.html#file-storage-on-s3

's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'token' => env('AWS_SESSION_TOKEN'), <-- here
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
    ],

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aristides Neto