/ #dev #js 

AWS S3 JS SDK Ignoring Endpoint Setting

I was setting up an application that connected to DigitalOcean Spaces, an S3-compatible object storage service. I was following this tutorial for an intro - because I’ve never used the AWS SDK before this.

Small issue - when configuring the S3 object and trying to connect, it would totally ignore the endpoint setting when I set it as the tutorial recommended:

// ❌ wrong
const aws = require("aws-sdk");

const spaces_ep = aws.Endpoint("ams3.digitaloceanspaces.com");
const spaces = new aws.S3({
  endpoint: spaces_ep
});

Annoyingly, I had to check-in with the AWS Node.js docs, which are impossible to find initially (for future reference). Here is how you are supposed to set your endpoint:

// ✅ right
const aws = require("aws-sdk");

const spaces = new aws.S3({
  endpoint: "ams3.digitaloceanspaces.com"
});

Annoying, right? It was just a string all along. I think maybe the tutorial needs to be updated.

Author

Matt Crook

Futurist, technologist, and student at Auckland Uni