khalsaniwas / aws

0 stars 0 forks source link

#5 - Load in credentials for AWS SDK #6

Open khalsaniwas opened 4 years ago

khalsaniwas commented 4 years ago

Per our research in issue #2 we found that a common prerequisite step for using the AWS SDK was setting up and loading in credentials to access our bucket. ​ We potentially have these from the setup when we downloaded accessKeys.csv This file had two keys, one called access key id and another called secret access key ​ This link may be useful: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html

khalsaniwas commented 4 years ago

We followed the directions of the link posted above.

  1. Created directory at root user (~) called .aws
  2. Created file in .aws folder called credentials
  3. Used this code example:
    [default]
    aws_access_key_id = <YOUR_ACCESS_KEY_ID>
    aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
  4. Replaced <YOUR_ACCESS_KEY_ID> with our access key id from accessKeys.csv
  5. Replaced <YOUR_SECRET_ACCESS_KEY> with our secret access key from accessKeys.csv ​ We are using the "default" profile because we only have one, and AWS will use these keys unless we say otherwise. ​
khalsaniwas commented 4 years ago

This code example is for double-checking credentials:

var AWS = require("aws-sdk");
​
AWS.config.getCredentials(function(err) {
  if (err) console.log(err.stack);
  // credentials not loaded
  else {
    console.log("Access key:", AWS.config.credentials.accessKeyId);
    console.log("Secret access key:", AWS.config.credentials.secretAccessKey);
  }
});

​ We will use this to double check our credentials before moving forward.