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:
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.
Environment variables are a great way to store values that will change based on your program's context.Aug 18, 2021