I'm trying to integrate S3 Bucket with my django application. But always getting this error.
raise ValueError("Invalid endpoint: %s" % endpoint_url)
ValueError: Invalid endpoint: <bucket_name>.s3.amazonaws.com
These are my settings.py configurations
AWS_ACCESS_KEY_ID = config('STATIC_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('STATIC_SECRET_KEY')
AWS_S3_REGION_NAME = config('AWS_REGION')
AWS_STORAGE_BUCKET_NAME = config('STATIC_BUCKET_NAME')
AWS_S3_ENDPOINT_URL = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
AWS_DEFAULT_ACL = 'public-read'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATIC_URL = 'https://%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_LOCATION)
I have referred the answers here, ValueError: Invalid endpoint: https://s3..amazonaws.com
Region is set correct.
The problem was because you didn't allow your s3 bucket to be accessible. Please learn How to add Bucket policy and permissions for public access.
And in your settings.py file. I added my Configurations like this: