My website index.html style broken after I configure aws S3. I added following code in my settings.py:
AWS_S3_ACCESS_KEY_ID = "my_key"
AWS_S3_SECRET_ACCESS_KEY = "my_key"
AWS_STORAGE_BUCKET_NAME = "my_bucket_name"
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
AWS_DEFAULT_ACL = "public-read"
INSTALLED_APPS = [
'storages',
]
AWS_LOCATION = 'static'
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
updated1:
I added permission to public. I turned off Block all public access and also added Bucket policy and Cross-origin resource sharing (CORS).
Bucket policy
{
"Version": "2012-10-17",
"Id": "Policy294......",
"Statement": [
{
"Sid": "Stmt859....",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:DeleteObject",
"s3:GetObject"
],
"Resource": "arn:aws:s3:::my-bucket-name/*"
}
]
}
Cross-origin resource sharing (CORS)
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
where I am doing wrong?