DEV Community

Cover image for My Experience with AWS Elastic Beanstalk and python
Durga Prasad Katrapally
Durga Prasad Katrapally

Posted on

My Experience with AWS Elastic Beanstalk and python

I’m not from programming but wanted to start my learning with Python ! I recently purchased a Udemy course for Python for my personal learning and that had a project to build Web based portfolio. It also showed on how to host your Web portfolio using pythonanywhere.com. ( For those of you who do not what is Pythonanywhere.com, it is place to host your python application , you can actually host one application for free !!! That’s what I did on my Web portfolio ).

It was all fine and happy !!! Check the link below for Web portfolio:

http://durga533.pythonanywhere.com/

I’m avid lover of AWS and like the range of offerings it has .. So, I wanted to have my Web portfolio hosted on AWS to enhance my learning with Python and AWS. The straight option for me was to use AWS Beanstalk. This is a managed service which provides Platform as Service and you can run your code on small to medium work loads without worrying about the underlying Infrastructure.

Launching sample applications on beanstalk was very straight forward and the results are almost instantaneous ! But there are certain twists on actual code implementation. My code was getting uploading without any issue and application was showing healthy yet my end point URL was not reachable.

Alt Text

I got internal 505 errors, after a lot search on Web ( thanks Google and stackoverflow ) it was due to my application code.

There are two things that I did to keep this working.

First , Elastic beanstalk expects a file called “ application” on the top level of the your directory. If it does not finds one it would throw error like what I got. This is what I did. I renamed my previous server.py to application.py

Alt Text

Secondly, the story does not end here, I tried after renaming but still saw the error. I had to my variable for Flask from app to application.

Alt Text

These two changes helped me to finally launch the my Website on AWS. Tadaaa !!!!!!! Happy me !!!!

Alt Text

My Learning and conclusion:

Not every code that we see can be implemented as-is, every platform has its own dependencies that we should satisfy to host. Launching a sample application for learning gives us confidence but launching something in real world throws lot of challenges and great learning !!!!!

Top comments (0)