How to Deploy FastAPI on AWS EC2: Quick and Easy Steps!

Поділитися
Вставка
  • Опубліковано 19 сер 2024

КОМЕНТАРІ • 142

  • @pixegami
    @pixegami  2 роки тому +3

    💡If you want an even BETTER way to host your FastAPI, check out my video on how to use FastAPI with AWS Lambda: ua-cam.com/video/RGIM4JfsSk0/v-deo.html
    This is serverless and in most cases is superior to EC2 in terms of scaling and cost.

  • @xplorewithpathy1407
    @xplorewithpathy1407 9 місяців тому +17

    for anyone wondering how to save and quit
    you'll first need to return to command mode. You can tell you're in insert mode if you see -INSERT- at the bottom of the editor. To exit insert mode and go back to command mode, press the Esc (Escape) key on your keyboard.
    Once you are in command mode, you can save and quit by typing :wq. This command is a combination of :w (which saves the file) and :q (which quits the editor).
    Press Enter after typing :wq to execute the command.

    • @faizanahmad3452
      @faizanahmad3452 9 місяців тому

      i just spend 1 hour on this :(😑

    • @oscarvgx
      @oscarvgx 5 місяців тому

      god bless you

  • @jaykay999
    @jaykay999 Рік тому +1

    by the way guys, if you connect directly using aws interface, and you struggle to save the vim file where he adds the proxy pass and stuff. here is chatgpt answer to do operations for the vim file :
    vim has a steeper learning curve but is very powerful:
    Start in 'normal' mode (where you can navigate and use commands, but not type text).
    To enter 'insert' mode (where you can type text): Press i
    To save: First return to 'normal' mode by pressing ESC, then type :w and press Enter
    To exit without saving: Press ESC then type :q! and press Enter
    To save and exit: Press ESC then type :wq and press Enter
    Copy (called 'yanking' in vim): In normal mode, move to the line you want to copy and press yy
    Paste (called 'putting' in vim): Move to where you want to paste and press p
    Delete a line: In normal mode, press dd

  • @favs5286
    @favs5286 Рік тому +5

    great content, i learned so much in under 15 minutes

  • @jithinjagadeesh4471
    @jithinjagadeesh4471 4 місяці тому +1

    Thank you so much for this video. Helped me a lot in configuring nginx and deploying on EC2!

    • @pixegami
      @pixegami  4 місяці тому +1

      Glad it was useful! I recommend checking out how to deploy FastAPI to AWS Lambda as well (it's cheaper and easier to maintain).

  • @user-lm4gs6fc3p
    @user-lm4gs6fc3p 2 роки тому +1

    Thanks a lot! This is the only of thousands that realy helped me to launch my project!!!

  • @TheEricon
    @TheEricon Рік тому +7

    would be nice to see you implement the https version of this, amazing video!

    • @pixegami
      @pixegami  Рік тому

      Thanks for the suggestion!

    • @alberjumper
      @alberjumper Рік тому

      @@pixegami Is it done now??

  • @jspjsp30431
    @jspjsp30431 2 місяці тому

    thank's your kind video from south korea!

    • @justin23262
      @justin23262 2 місяці тому

      hi, can i ask? if I shutdown my computer, can people access my api ?

  • @shawn.builds
    @shawn.builds 8 місяців тому +1

    this worked for me. thank you very much sir!

    • @pixegami
      @pixegami  8 місяців тому

      Glad it helped

  • @kevon217
    @kevon217 8 місяців тому +1

    exactly what i was looking for. thanks!

    • @pixegami
      @pixegami  8 місяців тому

      Awesome! I'm glad to hear that :)

  • @HarshPanwar9524
    @HarshPanwar9524 Місяць тому

    Amazing tutorial. Thankyou!

  • @mariaponomarenko3006
    @mariaponomarenko3006 Рік тому +1

    You have such a nice voice 😍 THANK YOU FOR THE VIDEO

    • @pixegami
      @pixegami  Рік тому

      Thank you, glad you enjoyed it! 🫶

  • @alexandere9723
    @alexandere9723 2 роки тому +2

    Great Video, thank you very much. Works like a charm

  • @SantiagoZuluaga
    @SantiagoZuluaga Рік тому +2

    Great Video, using vim like a Crack!

  • @berkefekeskin9172
    @berkefekeskin9172 Рік тому +1

    Thanks for such a understandable tutorial.

    • @pixegami
      @pixegami  Рік тому

      My pleasure. I hope it helped!

  • @mapneto
    @mapneto Рік тому +1

    thank you very very much! Greate Tutorial and explanation.

  • @smitimaheshwari5595
    @smitimaheshwari5595 Рік тому +1

    Thanks a lot! This was really helpful. :)

  • @mil0rd78
    @mil0rd78 6 місяців тому +1

    Excelente tutorial, gracias por compartir tu conocimiento

    • @pixegami
      @pixegami  6 місяців тому

      You're welcome!

  • @yannickpokam3864
    @yannickpokam3864 2 роки тому +1

    Thanks Bro !!! this video help me a lot,

  • @arturoguillen90
    @arturoguillen90 2 роки тому +1

    Thanks brother, amazing job ...

  • @abbasali6588
    @abbasali6588 Рік тому +6

    Great video!!! You even cleared a lot of fundamentals for me! I believe the same concepts will work for any ubuntu vps right ? Other than an ec2 instance ?
    thanks!

    • @pixegami
      @pixegami  Рік тому +2

      Yup, I think most of the concepts will still apply to any kind of Linux VPS :)

  • @randomforest_dev
    @randomforest_dev 8 місяців тому +1

    I used to create a new domain config under 'sites-available' first and then link to 'sites-enabled' ? what is the right way?

  • @angelmata9607
    @angelmata9607 2 роки тому +1

    Thanks you very much it was very useful

    • @pixegami
      @pixegami  2 роки тому

      Glad to hear that!

  • @joseramon1017
    @joseramon1017 2 роки тому +1

    whoa! This is awesome 🌟 🌟 🌟 🌟 🌟

    • @pixegami
      @pixegami  2 роки тому

      Thank you! Cheers!

  • @dariusboteand7722
    @dariusboteand7722 3 місяці тому

    I'm using vultr, installed nginx and configured as shown. It just doesn't work for me, no matter how I edit this, the url just says that page isn't working... any idea?

  • @divyagarh
    @divyagarh 5 місяців тому +1

    Thanks for the video. Could you also make an video about nginx, gunicorn, supervisor and having a frontend like vue?

    • @pixegami
      @pixegami  4 місяці тому

      Thanks for the recommendation. I haven't actually used that stack much so I doubt I'll be able to make a good video on it, but I'll add it to my list of things to learn.

  • @yloibx
    @yloibx 2 роки тому +1

    thanks. very useful.

  • @jameskilibaha9398
    @jameskilibaha9398 8 днів тому

    thanks man be bless

  • @mikecmw8492
    @mikecmw8492 Рік тому +3

    It would be nice to see how to automate this. In this case you are manually typing a command. What would you use to automate a deployment to the EC2?

    • @pixegami
      @pixegami  Рік тому +2

      Good point. You'd have to set up a CICD workflow. I recommend GitHub actions. Here's a new video I just made on it: ua-cam.com/video/9uMcN66mfwE/v-deo.html
      The video doesn't look at EC2 specifically (I prefer Lambda for compute), but the concept's pretty much the same.

  • @FarhanAhmed1360
    @FarhanAhmed1360 Рік тому +2

    when I close my aws terminal then my fastapi app gone anyway. how to keep running my fast api app even I close my terminal ?

    • @pixegami
      @pixegami  Рік тому

      That's because the Fast API process also terminates when you disconnect from the shell. You have to run it in the background. NGINX should have a way to do that for you - but if it doesn't, then you can try other ways to run it in the background (or as a Daemon).
      I don't have a video on it yet, but maybe something like this from the command: stackoverflow.com/questions/44222883/run-a-shell-script-and-immediately-background-it-however-keep-the-ability-to-in
      Or there are some more options here: stackoverflow.com/questions/1603109/how-to-make-a-python-script-run-like-a-service-or-daemon-in-linux

  • @raidwair
    @raidwair 11 місяців тому +1

    No creo que hables español, pero te amo.

    • @pixegami
      @pixegami  11 місяців тому

      Thank you :)

  • @user-hj8vb7xv6e
    @user-hj8vb7xv6e 5 місяців тому

    Please let me know how to solve 404 error. Nginx not found and Bad gateway error.
    Im getting 404 error if i try to run the instance after couple of days of deployment.

  • @user-eg9dc8kz2d
    @user-eg9dc8kz2d 6 місяців тому +1

    thank you!

    • @pixegami
      @pixegami  6 місяців тому

      You're welcome!

  • @andriyOshtuk
    @andriyOshtuk 9 днів тому

    If you stop instance and start it again you are going to lose all your set up. How to make these usung "user data"?

  • @timo_b3
    @timo_b3 Рік тому +1

    Thank you!

  • @KTMedia-hx5gg
    @KTMedia-hx5gg 11 місяців тому

    I am having problem in nginx part, when I try to close vim there, it doesn't close directly, It says either write a command or press enter, and takes me back to the same interface where I can edit the file

  • @lamarkneris3367
    @lamarkneris3367 Рік тому +1

    Thanks a lot!

  • @steeeif
    @steeeif 3 місяці тому +1

    This videos shows how to test the app but it wont work due to server will be terminated once window is closed..

    • @pixegami
      @pixegami  2 місяці тому

      You can run the command with `&` at the end (on any Unix based terminal) and that should prevent the terminal from shutting down the process when it exits. They can continue to run in the background.
      But yes, if you want to go to production with this you'll need to quite a bit more work.

  • @satwikawasthi2002
    @satwikawasthi2002 Рік тому +1

    I couldn't understand if we launched our instance then AWS charged us and if not then after how much time it start charging?

    • @pixegami
      @pixegami  Рік тому

      As of 2023 (when I'm typing this) EC2 has a 1-year free tier for the micro instance type: aws.amazon.com/free/
      But if you use serverless hosting (Lambda) you can get something like 1 million free requests per month, which is much better in my opinion: ua-cam.com/video/RGIM4JfsSk0/v-deo.html

  • @woodyjo
    @woodyjo Місяць тому

    thank you for your help but I have a question in my case when I try to do "sudo service nginx restart" or "sudo service nginx start"
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
    it shows me this error how can I figure it out?

    • @MrKB_SSJ2
      @MrKB_SSJ2 20 днів тому

      syntax error in nginx

  • @edwardwong654
    @edwardwong654 10 місяців тому +2

    Nice example. Wouldn't it be easier to just use docker, and deploy it on container with k8's?

    • @pixegami
      @pixegami  9 місяців тому +1

      It might be, if you have experience with Docker and K8s already. Personally I think something like Lambda is better for APIs like this (I have a tutorial on that too). But I think having a basic EC2 example as a tutorial is the easiest to grasp (even if it's not the best way to build this long term).

    • @edwardwong654
      @edwardwong654 9 місяців тому +1

      @@pixegami Damn. I appreciate you replying. I am not worthy. :-) But thank you!

  • @amarnathreddysurapureddy9111
    @amarnathreddysurapureddy9111 7 місяців тому +1

    Hi Sir, 1) I followed your tutorial and i run the smallest Application with ec2 and fast Api. 2) I created big application in that static, templates and model folders is there . How can i include in configuration of nginx.

    • @pixegami
      @pixegami  6 місяців тому +1

      Nice work! I don't actually use NGINX a lot myself, so I think you'll have to look on your own how to integrate that with your FastAPI server. For FastAPI my preferred way to deploy it is actually to use Lambda functions like in this video: ua-cam.com/video/RGIM4JfsSk0/v-deo.html

    • @amarnathreddysurapureddy9111
      @amarnathreddysurapureddy9111 6 місяців тому

      I got it no need to mention anything. folder structure is important.@@pixegami

  • @justmiroslav
    @justmiroslav 9 місяців тому +1

    How did you put the cursor on --INSERT-- in the nginx file to write :wq and close it?

    • @xplorewithpathy1407
      @xplorewithpathy1407 9 місяців тому +1

      you'll first need to return to command mode. You can tell you're in insert mode if you see -INSERT- at the bottom of the editor. To exit insert mode and go back to command mode, press the Esc (Escape) key on your keyboard.
      Once you are in command mode, you can save and quit by typing :wq. This command is a combination of :w (which saves the file) and :q (which quits the editor).
      Press Enter after typing :wq to execute the command.

  • @anggipermanaharianja6122
    @anggipermanaharianja6122 Рік тому +1

    NICE

  • @eRiicBelleT
    @eRiicBelleT 5 місяців тому

    Can i expose it bia https without a domain?

  • @avighnajha7114
    @avighnajha7114 2 роки тому +4

    Hey, great tutorial. Im currently working on my first API for an android app and was wondering how the api connects to a database once deployed to cloud? Does the database also need to be uploaded? Im sorry if the question sounds dumb but im still learning.

    • @pixegami
      @pixegami  Рік тому +2

      Great question - That's the next step! If you host your FastAPI on EC2, you can just put the database on EC2 as well. But here I just released a video on how to host a serverless FastAPI (and use a serverless database with it): ua-cam.com/video/iLt00bqp6is/v-deo.html

    • @isaquehg
      @isaquehg Рік тому +1

      If you're using a NoSQL database like MongoDB it's easier, bacause it's already deployed, so you only need to use the connection URL string in the API and give the needed permissions

    • @aashishmanandhar5188
      @aashishmanandhar5188 Рік тому

      @@isaquehg bad suggestion imo, choice of db completely depends on the use case of the project. NoSQL might or might not fit into the usecase.

  • @dariusboteand7722
    @dariusboteand7722 3 місяці тому +1

    you missed the step for nginx where you show how to allow connection from firewall..... no wonder it didn't work for me first time I followed your tutorial

    • @pixegami
      @pixegami  3 місяці тому

      Hmm interesting, I must have missed that. Thanks for sharing your discovery!

  • @yura2110
    @yura2110 2 роки тому +2

    hey, how can you make the fast api /docs not visible from the users ?

    • @pixegami
      @pixegami  2 роки тому +1

      You should be able to turn it off like this: `FastAPI(docs_url=None)`.
      See this for more info: fastapi.tiangolo.com/tutorial/metadata/#docs-urls

    • @yura2110
      @yura2110 2 роки тому

      @@pixegami thank you !! have a great day

  • @suman6327
    @suman6327 11 місяців тому +1

    Thanks for this tutorial. Am new to AWS / EC2. Would like to know why would one need NGINX here ? Can't we spin up Fast API container & then access it using EC2 Public IP ??

    • @pixegami
      @pixegami  11 місяців тому

      You probably can, but using NGINX as a reverse proxy is a very typical design pattern for this type of app just because of the control and security it provides. But if you have a lightweight use case and don't need all the extra stuff that NGINX helps with, yes I think you can just use FastAPI on a fixed port.

    • @suman6327
      @suman6327 11 місяців тому

      @@pixegami I tried with & without NGINX - both work fine. Thanks 👍

  • @juliocesarpereirarocha3976
    @juliocesarpereirarocha3976 5 місяців тому

    I used this but give a 404 error in all situations

  • @ApartmentAngelsFireStarters
    @ApartmentAngelsFireStarters Рік тому +1

    Hi, love this vid, could you do a deployment video for ec2 or lambda where you deploy to a windows device?

    • @pixegami
      @pixegami  Рік тому

      Thanks! Although I'm not sure what you mean by deploying to a "Windows" device. Do you mean a EC2/Lambda that runs a Windows OS?

    • @ApartmentAngelsFireStarters
      @ApartmentAngelsFireStarters Рік тому

      Nah tbh I just wanted a way to self host my app with a static ip for freez thought ec2 would help out but yeah its all but if there's a way you could possibly display how you could port forward a fastapi app to https that would be a pretty good video, I haven't seen anything like that and I would appreciate it if you made a tutorial showcasing how you'd do that

    • @pixegami
      @pixegami  Рік тому

      @@ApartmentAngelsFireStarters EC2 will cost money after a year, and a static IP is hard for people to type and remember and it can change if you reboot the server. Also, setting up HTTPS means you have to manage your own certificate and expiry. You'll also have to figure out how to patch and update your host so it doesn't become vulnerable to new attacks.
      Managing all that is possible, but difficult. That's why if you want to deploy a new app, I recommend going serverless instead.
      Check out how to deploy FastAPI to AWS Lambda. It's free for 1 million requests per month, and comes with a free HTTPS API endpoint (better than a static IP).
      If you need to persist data, check out ua-cam.com/video/iLt00bqp6is/v-deo.html

  • @hectorherreraespinola6399
    @hectorherreraespinola6399 Рік тому

    HI! very good video. I have a questions. After stopped the virtual machine and restart it, the FastAPI app does not work. Should I change any information each time I turn off the created EC2?

  • @chetanpatel2282
    @chetanpatel2282 Рік тому +1

    @pixegami What about production environment?
    You explained how to run it.
    How can you keep it running if you are hosting on ec2 for production use?

    • @pixegami
      @pixegami  Рік тому

      For production, if you are building a new app, I recommend going serverless. It's much easier to maintain and keep running (you don't need to worry about scaling, patching, load balancing, security). Check out a similar video for how to deploy FastAPI on AWS Lambda here: ua-cam.com/video/RGIM4JfsSk0/v-deo.html
      And if you wanna add a database: ua-cam.com/video/iLt00bqp6is/v-deo.html

    • @chetanpatel2282
      @chetanpatel2282 Рік тому +1

      You tutorial is excellent but I found this tutorial. It can be used for production
      ua-cam.com/video/t2AXy2y61oE/v-deo.html
      Sharing this tutorial so that it will be helpful to others.
      I spent almost 8 hours finding this solution last weekend.
      Thanks for the tutorial and quick response.

    • @pixegami
      @pixegami  Рік тому

      @@chetanpatel2282 thanks for sharing!

    • @josephajibodu2377
      @josephajibodu2377 Рік тому +1

      You can use a process manager to keep it running. Just like it’s done in NodeJS.
      Something like pm2, systemd, or even supervisord
      The will keep the app running and even restart if it crashes.

  • @akhilsharma392
    @akhilsharma392 2 місяці тому +1

    which is better for api deployment ec2 or aws lambda

    • @justin23262
      @justin23262 2 місяці тому +1

      hi, can i ask? if i shutdown my computer, can people access my api ?

    • @akhilsharma392
      @akhilsharma392 2 місяці тому

      @@justin23262 if its on local host then no
      If you host it somewhere then yes

    • @akhilsharma392
      @akhilsharma392 2 місяці тому

      @@justin23262 look if you hosted it somewhere and make outpost settings for everywhere then yes anyone can access

    • @pixegami
      @pixegami  2 місяці тому

      Personally, I'd go with Lambda. Better scaling, better availability, less maintenance.

    • @akhilsharma392
      @akhilsharma392 2 місяці тому

      @@pixegami yep I consider lambda also btw I am fresher working with cloud new to me and Thanks for comments it gives me a support

  • @priyanshudeshmukh2431
    @priyanshudeshmukh2431 Рік тому

    Why doesn't ec2 download tensorflow

  • @leonardorojasquevedo9342
    @leonardorojasquevedo9342 Рік тому

    Hi good afternoon , one question, I closed the terminal CMD , the api no found why?, the instance do not start?

    • @pixegami
      @pixegami  Рік тому

      Yeah... that could be the case. If you run the API directly in the terminal, then when you close it, it might also terminate the API. You might need to run it as a background process, or as a daemon (agent).

  • @user-vm7od6lq4p
    @user-vm7od6lq4p Рік тому +1

    f***ing legend

  • @reocode
    @reocode Рік тому +1

    Might look unrelated, but...
    What's your firefox theme?

    • @pixegami
      @pixegami  Рік тому

      I don't use any special theme, I think it was just one of the in-built ones suggested my Firefox when I upgraded/downloaded it.

  • @user-zb9bp1jt4k
    @user-zb9bp1jt4k 6 місяців тому

    Hey,
    Great content.
    I have a question, if we stop the ssh session, will the server still be accessible from internet i.e. will the services still work?

    • @pixegami
      @pixegami  6 місяців тому

      Yes, it should be because the FastAPI server will still be running on EC2. However, you can still have the server crash and not recover. So even though this lets you set it up quickly, there's still a lot of work to do to make it resilient.
      You can also check out my other video on how to host this on AWS Lambda instead, which takes away a huge amount of the server management work you need to do: ua-cam.com/video/RGIM4JfsSk0/v-deo.html

    • @isthatkhensi
      @isthatkhensi 4 місяці тому

      @@pixegami Hi, thanks for the great tutorial. I followed the steps and everything is working. However once I quit running uvicorn on my local terminal, the server gives a 502 error. Could it be my instance settings causing this dependency issue?

  • @cyberpunk6654
    @cyberpunk6654 Рік тому

    how to make it work over https???????

  • @nizor_
    @nizor_ 2 роки тому +4

    how do i keep fastAPI app running in production?

    • @pixegami
      @pixegami  2 роки тому +3

      Good question. If you follow this AWS EC2 tutorial, you will have a server up very quickly - but it is quite fragile. It doesn't have mechanisms to handle traffic surge, outages, reboots, or host/software patching.
      If you wanna continue using EC2, you need to add something like a health check and a boot script so that the server restarts when it fails. You might want to put it into auto-scaling group and maybe behind a load-balancer.
      But if this sounds complicated - then the good news is that there is also a better solution. We can instead deploy FastAPI to something serverless, like AWS Lambda (or AWS Fargate) instead. That will ensure that it is live, scalable and production ready all the time. I'll do a video on that next if people are interested!

    • @yangwang9688
      @yangwang9688 2 роки тому +1

      @@pixegami I’ll be looking forward to seeing the tutorial on Lambda

    • @pixegami
      @pixegami  2 роки тому +2

      @Yang Wang Here's the video with FastAPI on AWS Lambda: ua-cam.com/video/RGIM4JfsSk0/v-deo.html Enjoy!👍

    • @yangwang9688
      @yangwang9688 2 роки тому

      @@pixegami I’ve watched the video, this is superb 🤩

    • @moayadalkhozayem4742
      @moayadalkhozayem4742 11 місяців тому

      you should've just mentioned that from the beginning smh...@@pixegami

  • @peterkim9696
    @peterkim9696 Рік тому +1

    What if you close your terminal in your local linux machine would your fastapi close as well on Amazon AWS?

    • @pixegami
      @pixegami  Рік тому

      Yup, general closing the SSH connection will also terminate the process.
      unix.stackexchange.com/questions/422188/sshd-into-a-linux-aws-box-how-to-exit-out-of-terminal-without-closing-script-r
      To work around it, you have several options. The easiest one is just to run the script as a background task.
      askubuntu.com/questions/396654/how-to-run-a-python-program-in-the-background-even-after-closing-the-terminal
      But a better way is to run it as a Daemon or a service, so it starts up with the system, and also restarts if it crashes.

    • @peterkim9696
      @peterkim9696 Рік тому +1

      @@pixegami I want to run it 24/7

  • @overneos2728
    @overneos2728 8 місяців тому

    Hello,
    I've been wondering, is it possible to use a port different port 80 ? And if you've covered this topic in another video

    • @pixegami
      @pixegami  8 місяців тому

      You can set FastAPI's server itself to a different port, but port 80 is the standard protocol for HTTP so if you want users to be able to access this via HTTP it eventually does need to be routed through 80.

  • @princemoronfolu
    @princemoronfolu 2 роки тому +1

    Now how do you secure this. Since this is just public facing. Is there any authorization process?

    • @pixegami
      @pixegami  2 роки тому

      That's an excellent question - actually I think I'll make a video on the topic of authentication next to cover it.
      But to specifically answer your question, the API itself will need some sort of auth capability. Anyone can hit the endpoint with a request, but a request must be 'authentic' to be processed (and bad requests rejected with a 401 or 403 error).

    • @pixegami
      @pixegami  2 роки тому

      For FastAPI (and serverless APIs specifically) the popular way to do it these days is by using JWT tokens.
      This means the requester must seen a signed token that proves they are authenticated, and authorized to use the API. The token can only be signed by the auth provider (such as Firebase, Auth0, Clerk, and more), but it can be validated by the anyone who has access to the public key (which your API will).
      Typically, the token is sent in the HTTP request header under "Authorization". FastAPI has support to deal with this: fastapi.tiangolo.com/features/?h=authentication#security-and-authentication

    • @pixegami
      @pixegami  2 роки тому

      Finally, to prevent an attacker from obtaining a token and re-using it to use the API on a victim's behalf, tokens are usually short-lived (they have an expiry time after a few hours).
      But to get access to a victim's token, the attacker would usually need to have access to the victim's local environment to begin with (e.g. a public computer in a LAN cafe that didn't get logged out).

    • @princemoronfolu
      @princemoronfolu 2 роки тому +1

      Thank you very much for your answer also how do i achieve persistence with my database model. My dat that has been pushed seems to be wiped out after a while

    • @pixegami
      @pixegami  2 роки тому

      @@princemoronfolu If you're using Lambda, that's expected because the function is 'created' clean at the start of most invocations. If you're using EC2, then files and things you create should persist, so I'd be surprised if something is wiping it out - maybe there's a script or something that resets it? I don't know.
      But in either case, you *shouldn't* really be storing your DB model in your compute environment anyways. It is unsafe, difficult to back up, and will not scale. You need a separate service to host your DB, and your compute (whether EC2 or Lambda) and talk to it with API calls. That's the best way to build it.

  • @panosp5711
    @panosp5711 2 роки тому +1

    My friend please highlight that you use python3.8 otherwise with python 3.10 you have to install 3.10

    • @pixegami
      @pixegami  2 роки тому +1

      Thanks for catching that!

  • @vamsyrraju
    @vamsyrraju 11 місяців тому

    how about https?

    • @pixegami
      @pixegami  10 місяців тому

      Hmm, it's pretty complex if you haven't done it before. You need to get a certificate for your app (from where like "LetsEncrypt"), maybe put a NGINX rule (or maybe FastAPI has native HTTPS integration, I'm not sure).
      Then you'd have to modify the EC2 instance and security groups to allow HTTPS traffic: docs.aws.amazon.com/cloudhsm/latest/userguide/ssl-offload-enable-traffic-and-verify-certificate.html
      Personally, I don't like to manage any of that stuff myself so I prefer to use something like AWS Lambda for my APIs, then use AWS ApiGateway to manage the endpoint (and configure HTTPS through it instead).