I am running a NodeJS application that uses the aws-sdk
library. I have the following environment variables exported:
AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXX
I can verify they are set correctly by running the env
command as well as by running console.log(process.env)
in my Node code.
When running my application I get the following error:
Error: ENOENT: no such file or directory, open '/root/.aws/credentials'
at Object.fs.openSync (fs.js:577:3)
at Object.fs.readFileSync (fs.js:483:33)
at Object.readFileSync (/app/node_modules/aws-sdk/lib/util.js:97:26)
at SharedIniFile.loadFile [as ensureFileLoaded] (/app/node_modules/aws-sdk/lib/shared_ini.js:19:18)
at SharedIniFile.loadProfile [as getProfile] (/app/node_modules/aws-sdk/lib/shared_ini.js:52:10)
at Config.region (/app/node_modules/aws-sdk/lib/node_loader.js:88:34)
at Config.set (/app/node_modules/aws-sdk/lib/config.js:448:39)
at Config.<anonymous> (/app/node_modules/aws-sdk/lib/config.js:283:12)
at Config.each (/app/node_modules/aws-sdk/lib/util.js:485:32)
at new Config (/app/node_modules/aws-sdk/lib/config.js:282:19)
at Object.<anonymous> (/app/node_modules/aws-sdk/lib/node_loader.js:99:14)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Obviously the exact problem is obvious I do not have a /root/.aws/credentials
file. However from reading, specifically here it seems that the sdk should automatically detect my environment variables and not need to have a credentials file.
My question is how can I get the aws-sdk
to use the credentials in my environment variables without erroring about not having an credentials file?