Setting static file in elastic beanstalk

Viewed 680

Trying to have django look for static files in the right directory, when hosting with elastic beanstalk.

Config file:

option_settings:    
 "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "static"

Getting error message:

ERROR Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: '/static/'): Unknown configuration setting.

Tried following code from the documentation as a test.

option_settings:
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: production.settings
  aws:elasticbeanstalk:container:python:staticfiles:
    /html: statichtml
    /images: staticimages

Getting the same 'unknown configuration settings' error.

2 Answers

It seems you are using Amazon Linux 2? If yes, then it does not support the aws:elasticbeanstalk:container:python:staticfiles.

From docs:

Configuring static files using the aws:elasticbeanstalk:container:python:staticfiles namespace is only supported on Amazon Linux AMI Python platform versions

The answer for Amazon Linux 2 is to change:

aws:elasticbeanstalk:container:python:staticfiles:
    /html: statichtml
    /images: staticimages

to

aws:elasticbeanstalk:environment:proxy:staticfiles:
    /html: statichtml
    /images: staticimages
Related