Configure Boto3 endpoint_url

Posted 5 August 2023 · 1 min read

Tags:

Being able to configure the Boto3 endpoint_url with an environment variable is a long awaited feature added in boto3 1.28.0.

When developing an application that uses AWS services a common approach is to use local services during development, such as those provided by LocalStack.

AWS SDK now supports configuring service specific endpoints through AWS_ENDPOINT_URL and AWS_ENDPOINT_URL_<SERVICE> environment variables.

With the following env variables:

AWS_ENDPOINT_URL=http://localhost:4566
AWS_ENDPOINT_URL_S3=http://localhost:4567

Boto3 will use these values to set the endpoint_url:

import boto3

db = boto3.client("dynamodb") # endpoint_url=http://localhost:4566

s3 = boto3.client("s3") # endpoint_url=http://localhost:4567

Related posts

Mocking Boto3 with pytest

Published · 1 min read

Mock requests to AWS services with pytest

Python TypedDict with Generics

Published · 1 min read

How to define a Python type for a dict with generic values

Using TypedDict with invalid attribute names

Published · 1 min read

How to use a TypedDict with item keys that aren't valid identifiers

Subscribe via RSS to get new posts delivered to your feed reader, or browse posts by tag.


Thanks for reading

I'm Alex O'Callaghan and this is my personal website where I write about software development and do my best to learn in public. I currently work at Mintel as a Principal Engineer working primarily with React, TypeScript & Python.

I've been leading one of our platform teams maintaining a collection of shared libraries, services and a micro-frontend architecture.

I'm from London and you can find me on a few different social media platforms: