The requirement is to host a Streamlit Application on AWS with a CI/CD approach. I stumbled upon one example provided by aws-samples: GitHub - aws-samples/aws-streamlit-deploy-cicd. Is this the best approach, or is the community aware of any other way to accomplish this task?
If you are uncertain, a good guide is this.
Thank you for your response.
Correct me if I am wrong but using the video you sent, we need to manually perform all the steps mentioned here to publish new versions, or am I missing something.
Yes, but there are easier ways to get it done especially if using Packer. With this, you create an AMI (Amazon Machine Image) - consider it as a virtual machine that you give instructions on what to do when an instance is launched. For example - install python and pip, then install the packages in the requirements.txt file (streamlit, pandas, numpy and other packages that are important to your app working), go to directory where app file is found and launch via command streamlit run <app file.py>
. All this is done automatically when the instance is launched.
So every time you update your app files (app.py and other files in the pages folder, excel file for data etc) that are visible in streamlit, you upload to aws via packer and then launch an ec2 instance that uses your custom ami. Probably best to create a launch template and attach your AMI to it but this means every time you create a new AMI and upload to aws via packer, you have to go to the launch template, create a new version (just change the AMI to the new one deployed via packer).
So the only manual thing you will need to do is to update your launch template and launch a new ec2 instance after you terminate your old instance.
For me, I used a load balancer and an auto scaling group so the only manual thing I did was upload files via packer to create new AMI, update launch template so future ec2 instances will use the new AMI I uploaded, terminate the current ec2 instance(s) and the auto-scaling group will create new instances using the latest version of the launch template. All in all, depending on packer upload, 8-12min job.
For me, I build a docker image, push to AWS ECR and then let it update in ECS when there is low traffic. I’m using fargate though so it might be more expensive than your solution. How small were you able to get the compute side runnin your AMI?
Interesting solution.
I built two AMIs, t2.micro and t2.nano. Total cost is less than $25 (i pay in pounds so its cheaper )
Though the EC2 compute price is around $4. The bulk of the costs comes from the load balancer.
I’ll dig up my costs. Yeah, my app load balancer doubles my costs.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.