Aws4fetch: a tiny AWS client


#1

Hey there – author of aws4 here, which I know a few of you have used to connect to AWS services from your workers.

I’m happy to announce I’ve finally gotten around to pushing up aws4fetch – an AWS client that you can use in Cloudflare Workers (and modern browsers) – much smaller than aws4 and uses the crypto libraries available in CF Workers directly:

It looks like this:

import { AwsClient } from 'aws4fetch'

const aws = new AwsClient({ accessKeyId: MY_ACCESS_KEY, secretAccessKey: MY_SECRET_KEY })

const response = await aws.fetch(MY_LAMBDA_URL, { body: JSON.stringify(event) })

You can see this in action in a proof-of-concept we developed at Bustle that does server-side rendering and fetching data from AWS Lambda in a CF worker: