An AWS wat?!

tl;dr different AWS regions have different APIs.

I've been using AWS via boto3 a bunch lately and testing can be a bit of a pain. To my great joy, there turns out to be a mock aws implementation: moto.

Moto support for boto is pretty good but support for boto3 is still a bit of a work in progress. In testing, I was finding a lot of functionality to be broken, in spite of it working for other people. Through some poking and digging, I discovered that the failures depended on the region.

Here's a chunk of test code that illustrates the issue: (Source)

import io

import boto3
import moto
import pytest

@pytest.mark.parametrize('region_name', [
def test_mock_s3(region_name):
    s3session = boto3.Session(region_name=region_name)
    s3res = s3session.resource('s3')
    s3bucket = s3res.Bucket('test_bucket')
    s3obj = s3res.Object('test_bucket', 'test_object.txt')
    data = s3obj.get()['Body'].read()
    assert b'abc' == data

Punchline: A call to "py.test" gives: .FFF.F.FFF

====================== 7 failed, 3 passed in 0.97 seconds ======================

Why the heck are the api calls of boto3 dependent on the region being called?