Python Runtime on Amazon Linux 2023¶
This tutorial describes runtime behavior for AWS Elastic Beanstalk Python on Amazon Linux 2023. It focuses on version selection, WSGI and Gunicorn behavior, dependency installation, and platform extension points.
Prerequisites¶
- A Python Elastic Beanstalk environment using Amazon Linux 2023.
- Access to application source (
application.py,requirements.txt, optionalProcfile). - Familiarity with environment configuration and deployment lifecycle.
What You'll Build¶
You will establish a runtime baseline that includes:
- Explicit Python platform branch selection.
- Deterministic dependency install via
requirements.txt. - Gunicorn startup through default behavior or
Procfileoverride. - Static file mapping and platform hook customization.
Steps¶
- Select Python platform version compatible with your app.
aws elasticbeanstalk list-platform-versions --filters "Type=PlatformName,Operator==,Values=Python" --region "$REGION"
- Keep
requirements.txtin project root for package install during deployment.
- Expose WSGI callable in
application.py.
from flask import Flask
application = Flask(__name__)
@application.get("/")
def health():
return "ok"
- Use
Procfilewhen you need explicit Gunicorn configuration.
- Configure static files mapping if serving static assets through proxy integration.
- Add lifecycle scripts in
.platform/hooks/for custom actions.
- Deploy and inspect runtime logs to confirm behavior.
graph TD
A[Source Bundle] --> B[Install dependencies from requirements.txt]
B --> C[Resolve WSGI entrypoint]
C --> D[Start Gunicorn worker process]
D --> E[Proxy routes requests]
F[.platform hooks] --> C
F --> D
G[Static file mapping] --> E Verification¶
Use these checks to validate runtime assumptions:
eb status "$ENV_NAME"
eb logs --all
aws elasticbeanstalk describe-configuration-settings --application-name "$APP_NAME" --environment-name "$ENV_NAME" --region "$REGION"
Expected outcomes:
- Platform branch shows Amazon Linux 2023 Python.
- Deployment installs dependencies from
requirements.txt. - Gunicorn process binds to expected port through
Procfileor platform default. - Hook scripts execute in the expected lifecycle order.