I'm encountering an AWS credential error when using the aws-sdk
version 2.784.0 in a JavaScript runtime environment. The error message is as follows:
Error: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
Infrastructure: My code is deployed to an EC2 instance, and it's expected to load credentials from an IAM Role and no accessKeyId, secretAccessKey and sessionToken are passed.
Steps to Reproduce: It's important to note that this issue is not consistently reproducible, but here are the steps that trigger the problem:
- Create an S3 stream to upload a file using the
s3:upload
API. - Continuously write content to the stream for approximately 30-40 minutes.
- Attempt to close the stream to create a file on S3, which occasionally throws the error mentioned above.
Strangely, on subsequent retry attempts, the operation works fine without any credential issues.
I appreciate any insights or guidance on how to resolve this intermittent AWS credential error when using the aws-sdk
for JavaScript.