Getting "Forbidden: null" in my Node.js application when trying to access files from my S3 bucket

getting synonym
getting synonym thesaurus
is getting a word
getting ready
obtaining
get synonym
getting in a sentence
getting in spanish

This is an issue I've encountered in the last couple of days in my Node.js application. I am running aws-sdk version 2.272.1.

The error comes from the function s3.headObject. I am not sure if it relates to the access and secret keys not being configured properly or something else but I've unable to fix this issue.

let awsParams = { Bucket: generic-bucket-name, Key: req.params.profile_image_unique_id };
    return s3.headObject(awsParams, function (err, data) {
    if (err) {
        return res.status(400).send({
             error_title: 'File failed to download, unknown error',
             error_message: 'File failed to download, unknown error'
        });
    }

        let stream = s3.getObject(awsParams).createReadStream();

        // forward errors
        stream.on('error', function error(err) {
            return res.status(400).send({
                error_title: 'File failed to download, unknown error',
                error_message: 'File failed to download, unknown error'
            });
        });

        res.set('Content-Type', mime.getType('.jpeg'));
        res.set('Content-Length', data.ContentLength);
        res.set('Last-Modified', data.LastModified);
        res.set('ETag', data.ETag);
        res.status(200);

        stream.pipe(res);
    });

This is the error I get when calling the s3.headObject function. The error message is not that helpful besides telling me that I have no access to the files stored in my s3 bucket.

{
Forbidden: null
at Request.extractError (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\services\s3.js:798:35)
at Request.callListeners (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request. (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
at Request.emit (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request. (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
at callNextListener (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\sequential_executor.js:96:12)
at IncomingMessage.onEnd (C:\Users\johnn\Documents\juristerra-v3\Express\node_modules\aws-sdk\lib\event_listeners.js:307:13)
at IncomingMessage.emit (events.js:203:15)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
message: null,
code: 'Forbidden',
region: null,
time: 2019-12-26T20:42:02.817Z,
requestId: '15B13D1F7B4432A3',
extendedRequestId:
'+0xHIoU3OZ7RoLBJFKp0CO6VO9qNet0g1gyPBoBUfTuboTa9f6FIHXA0/A+5wjYpLnpTFH4J5/8=',
cfId: undefined,
statusCode: 403,
retryable: false,
retryDelay: 55.89876980791042
}

Have any of you encountered an issue like this before?

getting, EXAMPLES FROM THE WEB FOR GETTING. He's getting old, and he's come along into his second childhood. "And you're getting it so� Synonyms for getting at Thesaurus.com with free online thesaurus, antonyms, and definitions. Find descriptive alternatives for getting.

The lambda can be granted permission to access s3 bucket using it's IAM role.

Here is how you configure the IAM role for lambda.

Reference: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-execution-role-s3-bucket/

Also you don't need return infront of s3.getObject if you are not using the promise syntax

Getting Synonyms, Getting Antonyms, 261 synonyms of getting from the Merriam-Webster Thesaurus, plus 366 related words, definitions, and antonyms. Find another word for getting. getting definition: 1. present participle of get 2. present participle of get . Learn more.

The Secret Access Key which you are using needs to have proper IAM policies attached to it while performing any operations.

GETTING, getting meaning: 1. present participle of get 2. present participle of get . Learn more. 261 synonyms of getting from the Merriam-Webster Thesaurus, plus 366 related words, definitions, and antonyms. Find another word for getting. Getting: to acquire complete knowledge, understanding, or skill in. Synonyms: learning, mastering, picking up…

Getting definition and meaning, Getting definition: Getting is the present participle of → get 1 . | Meaning, pronunciation Duration: 0:13 Posted: Mar 20, 2018 With all thy getting, get understanding.; That which is got or obtained; gain; profit. 1882, Charlotte Riddell, "Old Mrs Jones", in Weird Stories, page 135 She was always considering how to increase her "gettings," but she never gave a thought as to how she might save them.

GET (verb) definition and synonyms, It's getting late – I have to go. If that spot gets any bigger you should go to the doctor. get wet/cold/tired/ill etc: It was raining and we all got wet. get angry/upset etc� Synonyms for getting in Free Thesaurus. Antonyms for getting. 1 synonym for getting: acquiring. What are synonyms for getting?

Opinion, The G.O.P. may have had a politically expedient change of heart. Better late than never. get: [verb] to gain possession of. to receive as a return : earn.