Skip to content

Instantly share code, notes, and snippets.

@djshen-ponddy
Created October 13, 2017 06:20
Show Gist options
  • Save djshen-ponddy/0c44a5d835aad7746518d90c360a1297 to your computer and use it in GitHub Desktop.
Save djshen-ponddy/0c44a5d835aad7746518d90c360a1297 to your computer and use it in GitHub Desktop.
Customize AWS Elastic Beanstalk wsgi.conf without being wiped out after update of environment variables
files:
"/opt/elasticbeanstalk/hooks/configdeploy/pre/99patchwsgi.py": &file
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env python
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
import config
def main():
if 'EB_SYSTEM_STARTUP' in os.environ:
return
try:
WSGI_STAGING_CONFIG = config.get_container_config('wsgi_staging_config')
config.execute(['mkdir', '-p', '/etc/httpd/wsgi.conf.d'])
config.execute(['sed', '-i', '/\<VirtualHost \*:80\>/a IncludeOptional /etc/httpd/wsgi.conf.d/*.conf', WSGI_STAGING_CONFIG])
except Exception, e:
config.emit_error_event(config.USER_ERROR_MESSAGES['badappconfig'])
config.diagnostic('Error patching wsgi.conf during configdeploy/pre: %s' % str(e))
sys.exit(1)
if __name__ == '__main__':
config.configure_stdout_logger()
main()
"/opt/elasticbeanstalk/hooks/appdeploy/pre/99patchwsgi.py": *file
"/etc/httpd/wsgi.conf.d/enable_auth_header.conf":
mode: "000755"
owner: root
group: root
content: |
WSGIPassAuthorization On
@ankitbeohar90
Copy link

@djshen-ponddy can you elaborate steps how to deploy this script and will it be applicable in autoscale case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment