I'm using AWS for executing some functionalities of our project. Here's the AWS configuration that's being implemented on our project file.
const aws = require('aws-sdk');
const lambda = new aws.Lambda({ region: 'us-west-2' });
const AWS_REGION = 'us-west-2';
aws.config.update({ region: AWS_REGION });
aws.config.update({ accessKeyId: 'MYKEYID', secretAccessKey: 'MYSECRETACCESSKEY' });
now, when I consume aws, for my functionality here
lambda.invoke({
FunctionName: "html-to-pdf", //all environments to call this same utility function. Don't prefix with dev-, prod-
InvocationType: 'RequestResponse',
Payload: s({ html_base64: base64data })
}
It gives me an error like this,
convertHtmlToPdf.err CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
at Timeout.connectTimeout [as _onTimeout] (D:\NEW\NEW\Web\thirdparty-api\node_modules\aws-sdk\lib\http\node.js:69:15)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
generateDocument.err Error [CredentialsError]: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
at Timeout.connectTimeout [as _onTimeout] (D:\NEW\NEW\Web\thirdparty-api\node_modules\aws-sdk\lib\http\node.js:69:15)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7) {
code: 'CredentialsError',
time: 2022-06-01T15:38:10.355Z,
retryable: true,
originalError: {
message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: 2022-06-01T15:38:10.355Z,
retryable: true,
originalError: {
message: 'EC2 Metadata roleName request returned error',
code: 'TimeoutError',
time: 2022-06-01T15:38:10.354Z,
retryable: true,
originalError: [Object]
}
},
errorLocation: 'generateDocument'
}
As you can see, I've already configured AWS parameters at the top of the file but still it is throwing me this error. I'm clueless here, Why is it throwing me an error when I've already configured it?
Any help is highly appreciated.