Error: Possible Unhandled Promise Rejection (id: 0): CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
I am using "aws-sdk": "^2.918.0" in a react native (0.64.0) project. I am running the program using node v14.17.0 and on a Windows 10 version 21H1 OS build 19043.985:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
AWS.config.update({
region: 'us-east-1',
maxRetries: 3,
httpOptions: {timeout: 30000, connectTimeout: 5000},
});
// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({
apiVersion: '2012-08-10',
});
console.log('ddb: ', ddb);
~/.aws/config
[default]
region=us-east-1
output=json
[profile myName]
region = us-east-1
output = json
~/.aws/credentials
[default]
aws_access_key_id=XXX...
aws_secret_access_key=XXX...
[mateo\.lara]
aws_access_key_id=XXX...
aws_secret_access_key=XXX...
When using ddb to query the database, I am getting this CredentialsError, despite having configured my credential in AWS CLI (aws-cli/2.2.6 Python/3.8.8 Windows/10 exe/AMD64 prompt/off). Do you know what the problem could be? And how to solve it?
-------------------------------------- EDIT -------------------------------------
As suggested by @nishkaush I have tried adding AWS_SDK_LOAD_CONFIG=1 to the config file, and I have tried deleting the credential file and adding aws_access_key_id and aws_secret_access_key to the config file without success.
Here is the output of the ddb log:
ddb: {"CALL_EVENTS_BUBBLE": [Function CALL_EVENTS_BUBBLE], "MONITOR_EVENTS_BUBBLE": [Function EVENTS_BUBBLE], "_clientId": 1, "_events": {"apiCall": [[Function CALL_EVENTS_BUBBLE]], "apiCallAttempt": [[Function EVENTS_BUBBLE]]}, "config": {"apiVersion": "2012-08-10", "apiVersions": {}, "clientSideMonitoring":
false, "computeChecksums": true, "convertResponseTypes": true, "correctClockSkew": false, "credentialProvider": null, "credentials": null, "customUserAgent": null, "dynamoDbCrc32": true, "endpoint": "dynamodb.us-east-1.amazonaws.com", "endpointCacheSize": 1000, "endpointDiscoveryEnabled": undefined, "hostPrefixEnabled": true, "httpOptions": {"connectTimeout": 5000, "timeout": 30000}, "logger": null, "maxRedirects": 10, "maxRetries": 3, "paramValidation": true, "region": "us-east-1", "retryDelayOptions": {}, "s3BucketEndpoint": false, "s3DisableBodySigning": true, "s3ForcePathStyle": false, "s3UsEast1RegionalEndpoint": "legacy",
"s3UseArnRegion": undefined, "signatureCache": true, "signatureVersion": "v4", "sslEnabled": true, "stsRegionalEndpoints": "legacy", "systemClockOffset": 0, "useAccelerateEndpoint": false}, "endpoint": {"host": "dynamodb.us-east-1.amazonaws.com", "hostname": "dynamodb.us-east-1.amazonaws.com", "href": "https://dynamodb.us-east-1.amazonaws.com/", "path": "/", "pathname": "/", "port": 443, "protocol": "https:"}, "isGlobalEndpoint": false}
