Problems uploading django static files to S3 using zappa

Good afternoon!

I'm deploying a Django project with Django Rest Framework (DRF) on AWS Lambda using Zappa. Everything is working so far, except for the Django admin, which appears unstyled and missing static files.

Following the documentation, I attempted to configure my static files to be served from S3 by running zappa manage dev "collectstatic --noinput". This command completes successfully, but when I check the S3 bucket, there are no static files related to my project (specifically for Django admin). Here’s my configuration:

Settings.py

java Copiar código

from pathlib import Path
import os

BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = ''
DEBUG = True
ALLOWED_HOSTS = ['*']

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'notification',
    'storages'
]

S3_BUCKET = "Name-bucket-s3"
STATICFILES_STORAGE = "django_s3_storage.storage.StaticS3Storage"
AWS_S3_BUCKET_NAME_STATIC = S3_BUCKET
STATIC_URL = f"https://{S3_BUCKET}.s3.amazonaws.com/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
AWS_S3_CUSTOM_DOMAIN = f"{S3_BUCKET}.s3.amazonaws.com"
AWS_ACCESS_KEY_ID = ""
AWS_SECRET_ACCESS_KEY = ""
AWS_STORAGE_BUCKET_NAME = S3_BUCKET
AWS_S3_REGION_NAME = ''

Zappa settings (zappa_settings.json)

json Copiar código

{
    "dev": {
        "aws_region": "",
        "django_settings": "core.settings",
        "profile_name": "default",
        "project_name": "djangotea",
        "runtime": "python3.12",
        "s3_bucket": "Name-bucket-s3"
    }
}

Problem: When I run the collectstatic command, it completes without errors, but no files are actually uploaded to S3. After enabling logging, I see an "Access Denied" error.

Question: How can I fix this access issue? Is there something wrong with my configuration? Am I missing any permissions?

Thanks in advance!

Вернуться на верх