My go-to method for gaining access to AWS using the Node.js tooling.
Long story short, it's Amazon — there are way too many ways to set credentials.
Though my preferred method is not the recommended way, I find that it plays well with setting other environment-based values for your application. That is by using environment variables.
The AWS SDK automatically looks for your credentials in environment variables. You can set the following values:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
Then it'll just work, like magic!
A big benefit to this approach is that you can have multiple projects on your machine and set these values contextually based on the project you're working with.
To learn more about setting variables in JavaScript, see this guide.