We're using Lambda functions and only for some executions, do we get this error.
Error [CredentialsError]: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
at Object.openSync (fs.js:497:3)
at Object.readFileSync (fs.js:393:35)
at Object.readFileSync (/var/task/back/requests/router.js:2:965376)
at constructor.o [as parseFile] (/var/task/back/requests/router.js:2:950732)
at constructor.loadFrom (/var/task/back/requests/router.js:2:951161)
at Object.getProfilesFromSharedConfig (/var/task/back/requests/router.js:2:978785)
at constructor.load (/var/task/back/requests/router.js:2:798037)
at constructor.coalesceRefresh (/var/task/back/requests/router.js:2:783742)
at constructor.refresh (/var/task/back/requests/router.js:2:798989)
at constructor.get (/var/task/back/requests/router.js:2:783568) {
errno: -2,
syscall: 'open',
code: 'CredentialsError',
path: '/home/sbx_user1051/.aws/credentials',
time: 2022-05-13T23:23:18.700Z,
originalError: {
message: 'Could not load credentials from constructor',
errno: -2,
syscall: 'open',
code: 'CredentialsError',
path: '/home/sbx_user1051/.aws/credentials',
time: 2022-05-13T23:23:18.700Z,
originalError: {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/sbx_user1051/.aws/credentials',
message: "ENOENT: no such file or directory, open '/home/sbx_user1051/.aws/credentials'"
}
}
}
I suspect that this is related to the lambda being triggered by an SQS event, not by the API?
I don't mind following the advice of any of the other answers on the subject, but it is really bugging me that only a few lambda functions are facing this issue and not all functions in the application.
False alarm.
I discovered having hard-coded credentials in one of the files calling aws-sdk, turns out it has nothing to do with dynamodab.