How to configure django storages authentication with AWS S3 and eu-south-2

0

I'm trying to configure Django Storages with authentication on eu-south-2 I'm receiving this error with status code 400

<Error><Code>IllegalLocationConstraintException</Code><Message>The eu-south-2 location constraint is incompatible for the region specific endpoint this request was sent to.</Message>...</Error>

My Django setup & config:

requirements.txt

Django==4.2.3
boto3==1.34.55
django-storages==1.14.2

settings.py:

AWS_ACCESS_KEY_ID = os.environ.get("AWS_S3_ACCESS_KEY_ID", None)
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_S3_SECRET_ACCESS_KEY", None)
AWS_DEFAULT_REGION = os.environ.get("AWS_DEFAULT_REGION", None) # value eu-south-2
AWS_S3_REGION_NAME = AWS_DEFAULT_REGION
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME",  None)
AWS_QUERYSTRING_AUTH = True
AWS_S3_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_DEFAULT_REGION}.amazonaws.com"
AWS_S3_SIGNATURE_VERSION = "s3v4"
AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"}
STORAGES = {
    "default" = {
        "BACKEND": "storages.backends.s3boto3.S3Boto3Storage"
    }
}
Alberto
asked 2 months ago81 views
1 Answer
2
Accepted Answer

Europe (Spain) eu-south-2 in the "opt-in" region. It is NOT enabled by default. Make sure you have enabled it Enter image description here

add AWS_S3_ENDPOINT_URL = 'https://s3.eu-south-2.amazonaws.com' into your settings

Here is a list of S3 endpoints: https://docs.aws.amazon.com/general/latest/gr/s3.html#s3_region

profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
Artem
reviewed a month ago
profile picture
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions