I’m not a regular poster around here but I have been working with Streamlit recently and absolutely love the tool. So much so that I used it in a recent project at AWS on model explainability. One of the requirements was a secure and robust dashboard deployment, and I separated this part into its own example that can be found on GitHub with CloudFormation templates included. I thought it might be useful for others looking to deploy their Streamlit applications with high uptime and access control.
Stepping through the architecture diagram above:
- SageMaker is used to deploy the example pre-trained DistilGPT-2 text generation model
- SageMaker is also used for Streamlit app development and testing (in Docker container)
- Elastic Container Registry is used to store the Streamlit app Docker image
- Elastic Container Service is used to run the Streamlit app Docker containers
- Elastic Load Balancing is used to distribute traffic between Streamlit app Docker containers
- Cognito is for user access management via username and password
User Access Management
All users of your dashboard will initially see a ‘Sign In’ screen, when trying to access the dashboard (unless you choose not to include this component in the CloudFormation template). You can create user accounts for the selected individuals who need to access the dashboard by providing their email addresses. They will receive a personalised email with their temporary credentials and a link to the dashboard. After first use, the user will be prompted to provide a new password. Cognito also supports other identity providers such as Google and Microsoft Active Directory, but that will need some tweaking of my CloudFormation template.
I’ve written everything up in more detail in a Medium blog post and there are lots of other details in the example notebooks. I’ve also provided a quick launch option for the CloudFormation template, so you can try the example out in your own AWS account in around 10 minutes.
Would be great to hear how others are deploying Streamlit on AWS (especially for the authentication part), and look forward to any feedback or questions.