When a Streamlit app needs more control over its hosting environment than a simple deployment platform provides, AWS Elastic Beanstalk offers a middle ground. It deploys and manages web apps on AWS while handling much of the infrastructure setup. You can still customize the environment when needed. section 12.0 section 12.3.2
Think of Elastic Beanstalk as a deployment concierge: instead of manually setting up servers, networking, monitoring, and scaling, you provide your application and let the service configure the components. It supports Docker and can be managed from a terminal with the EB CLI. section 12.3.2
Figure 12.4 The end state of the deployed Streamlit app on AWS
Follow a request through the load balancer to an EC2 instance and the Docker container running the Streamlit app. section 12.3.3
Elastic Beanstalk provisions components including EC2 instances, S3 storage, a Docker environment, a load balancer, and networking rules. The load balancer forwards requests to an instance; the app processes them inside its container. Elastic Beanstalk also monitors health and replaces failed instances. section 12.3.3
A practical deployment path for a Dockerized Streamlit app looks like this:
- Prepare the app for the hosting environment. A local Docker Compose mount of the .streamlit folder will not work in the same way on Elastic Beanstalk. One approach uses an .ebextensions configuration file to create secrets.toml on the EC2 instance and mounts that location into the container. section 12.3.5
- Run eb init from the app’s root directory. The guided setup asks for details such as the AWS region, credentials, application name, and platform. Choose a region with your users’ location in mind. section 12.3.6
- Run eb create to deploy the code to an environment. An application groups one or more environments, such as production and staging. section 12.3.6
- After changing the app, run eb deploy to deploy the new version. section 12.6
Adding a domain and HTTPS
A deployed app can use a custom domain and an AWS Certificate Manager certificate. After verifying domain ownership, add a listener on port 443 to the load balancer and attach the certificate. section 12.6
Elastic Beanstalk trades some simplicity for more infrastructure visibility and control than a basic hosting platform. When comparing alternatives for Streamlit, check WebSocket support: Streamlit relies on it. section 12.1.2 section 12.1.3
