Storage provider
s3nd with AWS S3
The original. Credentials come from the provider chain, so a Lambda or an ECS task needs no keys at all.
import { createBucket } from 's3nd'
// Credentials from the AWS provider chain: env, shared config, or the role.
const store = createBucket({
bucket: process.env.S3_BUCKET,
region: 'eu-west-3',
prefix: 'transfers',
maxSize: 4 * 1024 * 1024,
})Why this one
AWS S3
On AWS, s3nd is the AWS SDK v3 with the transfer semantics on top. Omit credentials and the default provider chain applies: environment variables, the shared config file, or the role attached to the instance, task or function. Nothing to store, nothing to rotate.
From the command line
A starter configuration, and what is left to do.
init writes the file with ${VAR} references rather than secrets, so it is meant to be committed; the env file it points at is not.
s3nd init --provider aws --bucket transfers{
"bucket": "transfers",
"region": "eu-west-3",
"prefix": "transfers",
"expiresIn": "24h"
}Then
- 01Give the machine credentials the usual way: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, a profile, or a role.
- 02Add a lifecycle rule on the transfers/ prefix that expires objects after a day or two.
- 03Run
s3nd doctor. It performs the operations s3nd needs and reports what happened.
Worth knowing
Notes on S3.
Virtual-hosted addressing
Without an endpoint, s3nd leaves path-style addressing off, which is what S3 proper expects. Set forcePathStyle yourself only if a gateway in front demands it.
ACLs are off by default
Buckets created after 2023 have "bucket owner enforced" on. Make objects public with a bucket policy or a CDN, and leave the acl option alone.
Expiry cleanup
expiresIn stops a transfer being handed over; only a lifecycle rule deletes the object. Give the prefix a rule that expires objects after a day or two, and s3nd doctor turns green.
Other providers
The endpoint is the only difference.
Put a file. Hand over the code.
Point it at the bucket you already pay for. Nothing to deploy, nothing to sign up for, nothing in the middle.
npm install -g @s3nd/clis3nd init --provider r2 --bucket drops3nd put ./anything.zip