I'm using v3 of aws-sdk, trying to follow the reference docs exactly, but cannot load credentials.
const {fromIni} = require("@aws-sdk/credential-provider-ini");
const credentials = fromIni({});
... gives the error:
Unhandled Rejection (Error): Profile default could not be found or parsed in shared credentials file.
And:
const {parseKnownFiles} = require("@aws-sdk/credential-provider-ini");
const pkf = parseKnownFiles();
... gives the error that I think may be the cause:
TypeError: Cannot read property 'loadedConfig' of undefined
If it can't find a known credentials file then it's certainly not going to find default in there.
Yet I'm certain the credentials are there:
PS C:\> aws sts get-caller-identity --profile="default"
{
"UserId": "*********************",
"Account": "************",
"Arn": "arn:aws:iam::************:user/*****"
}
How do I load my credentials in aws-sdk v3?
You need to pass AWS
profile
intofromIni()
. It isdefault
in your case.