SDK

Credentials

You can find information about SDK credentials here.

You can give the AWS SDK automatic access to AWS credentials by saving your AWS account credentials in a .aws folder in your home directory in a file called credentials.

[default]  
aws_access_key_id = <YOUR_ACCESS_KEY_ID>` 
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>

You also may need a to add a session token if you are using session based AWS access which you can do by adding the aws_session_token property to the credentials file as well as the key and secret key properties.

aws_session_token = <YOUR_SESSION_TOKEN>

S3

Javascript

You can load a resource from S3 using the AWS SDK with the S3 object.

var AWS = require('aws-sdk');

getS3Content = () => {
  var s3 = new AWS.S3();
  var params = { Bucket: "my-bucket", Key: "my-file.txt" };
  var data = await s3.getObject(params).promise();
  try {
    data = await s3.getObject(params).promise();
  } catch (e){
    data = e.toString();
  }
  return data.Body.toString();
}