How to Deploy Python Applications to AWS (Amazon Web Services)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello students I'm Pathways and welcome to my another video on building web application with python flask and also AWS or Amazon web services but before that if you're interested on a complete course on working with Amazon web services with Python programming language then you can join my complete course my 24 hours training course on Amazon web services with python and budo 3. so now let's talk about the course of structure now uh where you need to start from a flask fundamental concepts and we are going to talk about the fundamental concepts of the flask and after that we're going to talk about the Amazon artist or relational database service and we wanted to create that with our flask web application after that we are going to deploy our flask web application to ec2 Amazon ec2 or elastic compute cloud and after deploying to the ec2 we are going to talk about application load balancer and we're going to integrate application load balancer with our Eastern instances after that we are going to talk about Route 53 Amazon route without 53 and we're going to add a custom domain name uh to our flask web application and at the end we will talk about the ACM or Amazon certificate manager and we are going to secure our web application with Amazon certificate manager so now let's start our course when it comes to Python programming language there are different options that you can use for building web applications now one of those options are flask now first of all what's flask flask is a microwave framework that is used for building web applications and Python programming language now when we're saying that flask is a microwave framework it does not mean that you cannot build complex applications complex web applications using flask but flask by itself is a microwave framework but you can use for example extensions on libraries that are available for for the flask and you can make your web application more complex for example if you're using a uh orm functionalities then you can use flask SQL Alchemy or if you're using for example uh forms inside flask then you can use flask WTF so now like this you can use extensions and flask uh let's install flask we are going to install flask and also we will create our first hello world web app using flask so now I'm using pycharm ID now the first thing is that you need to create a project in pycharm ID you can just go to the file new project and from here you need to just choose the name of the project and after that we are using we want to create a virtual environment you can just choose this and you need to choose your python version and you can just click on create your project will be created now make sure that you can you give the a name for the project and after that you can just click on Create and your project will be created so after that you can just use terminal inside pycharm ID so you can see that up at the bottom we have terminal we can just click on this and now you can see that by default the virtual environment is activated and my pycharm ID and now I can directly install flask so I can just use pep so pep install flask hit enter and it will take a little bit for the installation so now that's installed and it's installing the flask okay so now flask is installed after installation of the flask now we want to create our first hello world web app using flask uh the first thing is that we want to create a python file you can just right click new python file and I can just call it app.pify after that the first thing that we need we need to import our flask in here and I can just say from a flask import flask and after importing of the flask now we need to create our route so first you need to create your route and after that you need to create your view function okay and now I can just say at app.rout so okay so first we need to create our instantiate our flask and after that we can just create our route so I can just say app flask I'm just going to underscore name we can pass and now we can just use as we can just use at app.rout and for example we want this should be index okay or slash now we can create our view function and I can just say diff index and this is our index route and the index what I want to do I want to just return hello world so I can just say return hello world so now we have installed flask we have imported the flask we have instantiated the flask we have created our route and we have created our view function and and there we are just returning a hello world text okay now now what we need to do we need to just run our development server uh because we want to test this that it is working or not and I can just say underscore underscore Main and inside the flask app you can just use app dot run and if you are for example and development mode you can just make the debate through okay and the production level you can just make it uh you can just remove that okay so now if I just run this uh so okay so right now you can see uh we have all things that are set up and now if I just run this uh you can just right click uh that you can just click on run so now here you can see that we have we're starting with State debugger is active and that's because because we have to back to true and now uh you can see that we have a running uh so server flask app and this is the developer server do not use it in the production deployment and now if I just click on this you can see that we have our hello world now for example if you change this to something more and welcome to the course for example and if I just save it and now it will automatically be refreshed and if I just refresh this you can see that we have that in here in a previous lesson we have created our sample web app sample hello world web app using flask and it's not something we want to talk about that flask template or how we can use templates inside a flask so right there you can see that we have our flask web app and it's returning just hello world text and if we see we have our hello world now uh for example if you want to build a complete web application now it's not a good idea to use uh a lot of things inside here even for example in here you can use the H1 tag for example uh we can just say H1 tag and if I just save it and if I just refresh it you can see that we have hello world but it's not the idea that we want to use for example for building a complete a complete web application you'll have HTML files you will have templates that you can easily use them so now the first thing is that we need we need to create a template for our this index view function and we want to name it index.html but this index.html should be inside templates folder now make sure we want to create a folder at name of templates and that should be in here okay so now I could just say templates so template and after templates now inside this templates you can create your HTML files so for example the first one is HTML and I can just call it index okay so now we have our index.html and now inside this index.html let me change the title to for example whom and and the body we want to just give and for example H1 tag so Welcome to the course and now we have this index.html how we can just show this in our this view function and instead of this text now there is something that's called render template and we can use that from flask and I need to import the renders template and in here I can just render templates so you can just say render template and there are different options that you can use in here uh some of them are required and some of them are not required for example the required option is the template name the uh HTML file name or the template name that you need to give it in here and the optional for example uh parameter parameters are for example if you want to send some data from your this view function to this HTML file then you can use that so we'll talk about that when we have fetched our data using from the database but right now to render our this index.html we need to just add that in here so I can just say index.html okay so now you don't need to give templates index.html because uh flask knows about this templates that we have and it will Target that so now if I just save it and if I just refresh it so you can see that we have welcome to the course and that's working so pets working we have our HTML file you can create another HTML file another HTML file according to your project okay uh now the problem is in here right now we have just one HTML file and there is no problem now in a complete a more complex project maybe you'll have more templates now in every template or in every HTML file writing this HTML tags are not a good idea because we are repeating the codes in here now there is something that's called template inheritance and flask that you can use so now what we need to do we want to create a base dot HTML in here so we are going to write our basis skeleton or skeleton of HTML in there and after that we can extend that base.html and our other HTML files so now let me show you that what I mean for example and here I want to create another HTML file and I can just call it base.html file and in the base.html file by file by the help of the blocks we can create blocks in here so for example we want to create one block for the title that should be before the title so block title and in here I can just end the blog so when you create a blog make sure to end the blog you can create more blocks button here uh and my project requirement we need just two blocks one for the title and one for the body and I can just say block body and I need to end the block okay so and block so now we have our base.html and we have two blocks in there now we can easily use this template so we don't need this these HTML files in here what we need we need to just extend from base.html so base.html and after that we can use the blocks that we have created so for example we have one block for the title and I can just name it home you can end the block we have one block for the body so block body and we can end the block foreign body we can just write our body so let me create an H1 tag welcome to flask and eight of these colors and also we can just create a P tag and here and I can just say please subscribe my channel and like the video let's save it and let's check it so now you can see that we have our text in here we'll come to flask and AWS course and also we have our PTEC now I can create for example more HTML files and I can just extend from the base.html I can give for example the title and after that I can just write the body we already have learned about some basic and fundamental concepts on flask now let's start our database programming and we're going to talk about a flask SQL Alchemy so first of all what's flask SQL Alchemy now flask SQL Alchemy is an extension for flask that adds support for SQL commute to your application it simplifies using SQL Alchemy with flask by setting up common objects and patterns for using those objects such as session type to each web requests or models and also engines so now let's install flask SQL Alchemy and let's practically work with that now this is my flask project the first thing is that I need to install flask SQL Alchemy so I can just say pep and install and I can just say flask SQL Alchemy and hit enter and it will be installed after doing that we need to add configuration okay now when you're using flask SQL committer different database options that you can use for example you can use sqlite you can use MySQL you can use postgres now in this lesson we are going to use MySQL and particularly in this course we can see we are using mySQL database and for right now you're using wamp server but we will change this to Amazon RDS or relational database service okay now we'll talk about all these more now it's a relational database service from the Amazon that you can create a different DB instances like MySQL postgres or like these databases we will change this but for right now for testing purpose we're using wamp server and after completing of our project we are going to just migrate to Amazon artist or relational database service so now uh so the first thing is that we need to create a database and I can just oh I have open My Alarm server I can click on new and for example I can just name it flask AWS okay so flask AWS and let's just click on create database so right now we don't have any table and this flask AWS after doing that we need to add our configuration okay so now if you see uh if I show you for the configuration so you can see that you there are different uh ways that there are different configuration for different databases so if you're using sqlite you can use this but if you're using MySQL you can just use this so I'm going to just copy this and after that I can just open my app.pi file and in here the first thing is that we need to install that we need to import that from flask SQL Alchemy we want to import SQL Alchemy and after doing that in here we need to create our configuration so I can just see app dot config and I can just say so SQL Alchemy database URI and in here we can just paste this okay and for the database URI so we are using MySQL and we need to change this to root the username so the username is root we don't have any password for this and we can just make it like this now this is localhost now this is the server we will change this with the RDS servers but right now we're using localhost and the database name is what was uh it was flask awnias flask AWS okay and after that also we need to just add another configuration so I can just say app dot config and I can just say SQL Alchemy underscore track underscore modifications so moody notifications and I can just make these two folds okay so now we have our we have added our database configuration after that what we need to do we need to add that to the flask and I can just say SQL give me and I can just say app okay so after doing this right now if you see we don't have any table in our database what we need to do we want to create a table okay or we can say we want to create a model okay and basically models are classes python classes that we can use that extends from the DB dot model so for example I want to just create a class book and it extends from DB dot model and after that I want to just give the item here and I can just say DB dot column so you need to give the type that's DB dot integer and the primary key is true okay primary key true after that we need to give the title we will have a title for the book so DB dot column and it should be a type of string and we want to give the 100 characters and also for example it should be nullable to false it means that we want that field and let's just also we want to create one for the author so author foreign and one for the price and I can just make a DB for example dot float so price DB dot column DB dot float okay so now uh after doing this uh after creating of this model let's just also create our edit and here so underscore and it and and here I need to pass the title I don't need the ID because ID will be created automatically I need the author and also I need the price okay and now I I can just say so the title to title and solve dot author to the author and solve dot price to the price okay so now we also need to because we are using mySQL database we need to install another Library that's called MySQL client but if we're not using MySQL for example you're using sqlot for sqlite you don't need to install anything and for the postgres you need to install another library but for the my skill we can use my school client so I can just say uninstall MySQL client okay so the MySQL client has been installed after doing that what we want to do we want to just uh open flask cell and uh we need to create our this table okay so right now we have just the model in here but that's not added in our database so I can just say flask shell and after that hit enter so now the flask shell the first thing that we need we need to just import so I can just say from app I want to import DB okay so from this file I want to import this DB okay and after doing that what we want to do we want to do db.create all so DB dot create underscore all hit enter okay so now let's create it and if I check my flask awds you can see that The Book Table is created where the fields ID title auto run price okay now this is working after doing that now let's just do add some data using the flask shell and for example I can just say book I do need to add the ID because that will be automatically created so title python we want the author for example the author we can just give an author in here and also we can just give a price for example 20 okay after that hit enter and now we can just say DB dot session dot add and we want to add the B and also we need to commit so db.session dot commit hit enter so now if I check you'll see that I have my first data in here so if I just go to the flask AWS if I go to the book and now we have our first data so now let's add another data so I can just say book and I can give the title so for example uh flask author and price db.session dot add you want to add the B and also you need to commit so db.session dot comet and now if I check you'll see that I have another data so we have two data also you can select the data let's just select the data for example in here I can just say book underscore data and I can just cutie that so book Dot cutie.all and now we if I say book data we have two data and now I can iterate that so for a book and book data and then here we can just print for example I want the title so print book the title and now we have the title in here uh also you can update the data if you want for example I can just say updated so updated and let's just say book dot QD dot filter underscore by up I want to filter according to the ID so for example I want to get the ID one and I want to update that so dot first and if I say app dated you can see that we have the id1 and now I want to change the title so updated.title to for example updated and we need to just say DB Dot session dot commit foreign okay so now if I check this you will see that now the first ID is updated the title is updated uh pulse you can delete the data so I can just say delete it and book dot cutie Dot filter underscore by and I can just pass id21 DOT first and after that if I say delete it we have the deleted data and now we can just easily delete this so DB DB dot session Dot delete you want to delete it deleted and DB dot session Dot comet so now if I check this class kws book and now we have just one data in the previous lesson we have learned about the flask C2 Alchemy and also we have added some data and also we have learned that how we can work with mySQL database and also Flats now I just listen what I want to do I want to show my data from my database from my mySQL database to the HTML file that I have so now let's do that so right there if you see we have our some Demi data and our index page now if you see we have a data in the database now we want to fetch this data from the database and we want to show that in our index.html but before that because we are using bootstrap and you need to just go to the getbootstrap.com and from here we can just copy the links so this is for the CSS I can just copy that and the best places the base.html because we are extending from that and I can just paste that in here okay and also we need the JavaScript bundle so let me just copy that and we can just add that at the bottom okay and here so now after doing that we want to open our app.pi file and in here uh in this section the first thing is that we need to query over the book so using a SQL Alchemy so we already have learned uh using the flask shell so I can just say books and I can just say book Dot cutie.all so now we have all the books from our database and now we can send these books to this index.htario and we can just do that like this okay so I can just say box and box okay so now we have box and now we can access that inside the index.html so I'm going to open my index.html and I don't want uh and I don't want this text because now I want to use uh the data from my database so we need to use some bootstrap styles for example first we are going to create a the dev div class container so container and after that in here we are going to create a table so table and I can give you a class so for example so these are bootstrap classes that I'm going to use and also I can just hit table strapped and it should be table however okay so now inside this let me just create a table header and after that let's just create table row and let me create a th and inside that for example we have ID uh we have a title so title and also we have the author and we have the price okay so now after that we need to create our tea body in here and let me just say t-body and then the tea body we are going to just use for Loop and we want to trade our data that we have so in here I could just say 4 book in books now the Box this is that we have used them here okay so I can just say for book inbox and also you need to end the for Loop in here so so we can just say and for Loop and now and here we can just use TR and side TR we can create our TD and we want to show the data so first we want to use book dot ID and let's create another 2D and for this I can just say book dot title and we have book dot author so TD and we have book dot author and last one is the price and so TD book dot price book dot price okay and also we need two buttons because we will use that for editing or deleting the books and also we want to create that in here we will need that so I can just create another TD in here and inside this TD let me just create a anchor tag and for the ref I would just leave it empty for right now and the class is BTN BTN uh we can just use a bootstrap between like this uh so let me remove this we don't need this and also uh because we will use models so here you need to give the Target and also uh that we need to give the toggle also the target so now in here I can just say data BS toggle and also or Friday we are not going to give this okay so we want to just give a simple button I don't want to confuse you for right now it should be update and let's just create another one and that should be for the delete okay so I can just change this to Danger so danger and I can just make it delete so right now we are done I think and if I check this so let's just go to the home page and Let me refresh it okay so now you can see that we have this but the design is not looking good and maybe there's a so right there you can see that we have the data and that is working but now we need to check that where is the problem and the bootstrap design okay so we have the container table class table table table is strapped table hover let me also give a border in here it's also good so let me just give a border so order one so t-head t h t h t h there is no problem tea body and then the tea body uh we have this and there's no problem uh just the problems and the axles and that's because because we need to create an action in here so and the th and in this section we can just give a call span of two so pull a span of two and I can just say actions let's save it and let's refresh it okay so now it's looking good and also we can just give a margin top four okay so now that's looking good and for the actions if I uh remove this cooler span let's check that how it's looking now I've removed this mt4 and let's just remove this okay so we need to give that uh we need to give a color span okay so now it's looking good but there's some space uh if I just uh bring this also in here inside this TD let's check let me remove this one let's save it okay so now that's looking good okay so now we have this we have our first data now for example if I insert another data let's just go here and if I go to the uh this table insert and we don't need the ID for example I can just say flask the author and the price and let's just click on go and now the data is added and if I check this so now we have another data in here flask uh so we okay we have to flask yeah and we had already a flask in here but no problem and now you can see that we have two of them and that is working and this lesson we want to add an advert or flask web app so now here at the top I want to add an hour and also this will be a good that you will be familiar with another uh thing that's called include okay so uh now I'm going to uh first also uh I will show you that how you can use static files for example I will add a logo in there so for that you need to create another directory and here you need to call it static okay so for example if you have your own CSUS then you can add that in here okay so now I'm going to just paste a flask.png login here after doing that in the templates I'm going to create another Temple HTML file and I can just call it navbar and in the nav bar I want to create my number so this should be a bootstrap number and I can just say nav and so in here I can create my class so that's nav bar spent LG and number we need to give the color so I can just say light BG light and we can create a div in here so the class container container and inside this class container we want to create an anchor tag and I can just say a class now board Branch so now bar brand and we are going to give a riff so I can just leave it empty and then here we want to just use our image okay so IMG now the first thing is that we need to give the source of the image and uh so I can just say source source is required and for this we have our static folder and we have added our image in here now we can use url4 and we want to search in the static folder and the file name is flask.png it's a fast dot PNG and also we need to give some for example you need to give the alt in here so uh I'm going to I I'm leaving empathy or I don't need to give that but we need to give the wet so 100 and the height uh 50 and also we need to just use a class from bootstrap and I can just give the class in here I can just hit d n line block and we want to align that to the top top of the text story so if we have a text in here right now we haven't done the text we have just the logo so now we have this after that now we want to include that and our base study student for example in the head I can just include that so I can just say uh for example uh include and that is navword.html let's save it and let's refresh it so now you can see that we have our number in here and also we have our logo and that is working okay and the network in this lesson we want to work on inserting functionality but we will not insert the data we want to just create our design that will be a Model A bootstrap insert model so now let's do that so now the first thing is that if you see in here we have our number in here we want to create a button so for example add book uh to do that we want to just open our navword.html and then here after the Linker tag we want to create a UL class and I can just say navbar nav so navbar nav and inside that we want to create a button so button and we can give the class so that is BTN B10 for example we can use a bootstrap class and I can just say add book okay uh okay so there should be an ally tag so l i and we can give the class to nav item so nav item so let's just let's remove this from here and we want to just close it in here so now if I just save it and if I refresh it you can see that we have article so for example by clicking of this we want to just show a bootstrap model Okay so now I already have prepared the model and I want to just copy that this and paste it in here don't worry you can just get the source code of this project from the video description okay so now after the in the navword.html we want to just paste the model now I'm going to just describe this model so now this is the ID and insert model and this is the class so this is the rule dialog okay and these are some bootstrap classes there if you see they get bootstrap.com there are a lot of models you can just copy one of them and you can just make it according to your choice so this is the model contained this is the mother header model header we have the ad book header and after that this is the body now this is the form action right now we are not doing anything but after that we have the fields we have the form group we have the title so this is our title and the input type is text this is the class form this is the name the name is title now this is important because you will need this and record this one okay also we have the the author the same option we have for the author but make sure to change the name to the author and we have the same option for the price make sure to change the name to the price and also for the price input type is number and this is the button that will be for adding the book so we can just say add book okay and also we have a footer for the model and there should be just a button for closing of the model okay so this model folder so now we have the model after that what we want to do we want to just link this model to our button so if you see in here we have a button and that button is located inside our Network so we want to just link this model to this at book button so uh we have this in here and this is the button and now in here we can just use data BS toggle so data not dismissed but it should be toggle so toggle and for that we want it should be model and also we need to give the target so data BS and we want the Target and for the Target we are going to Target this model so if you see that as the ID is insert model so we need to just copy that and we are going to just add it in here okay so like this insert model let's save it and let's check it refresh if I click on ADD book so now you can see we have our model ad book title auto price and we have ad book and we have a Clues and we can just close that so now we have our nice model in the previous lesson we have learned that how we can create our model and that's not something we want to learn that how we can insert our data so now we can see if I click on ADD box you can see that we have a nice model that we can just add the title alter and the price and after that we can just click on ad book now we want to just using this form you want to just insert some books or some data to our this table so to do that what we want to do we want to just open our apps.pi file and in here we want to create another round so okay so I can just hit app so daughter out and then here I want it should be add and after that we can just say methods and that is post so I could just say post so after doing that now I can just hit the insert underscore book first I want to check that if request so if we need to import the request so from flask Quest and I can check that ifrequest dot method as post in that case what we want to do we want to just instantiate our bulk with the data and we can just say title and I can just say request dot form dot get title and we have the author request.form.author so dot author and I can just say author foreign get and also we have the price so request .form dot get price now after doing that we already have learned that we can use this session so db.session dot add and we want to add the book after that we need to just commit so db.session dot commit and at the end we after inserting we want to just redirect so we are going to use redirect from flask to the index page so after exerting the data so you can just say redirect I need to import that and then here I can just say return redirect to the also we need to import the URL for so URL for uh okay so now we can just say URL for to the index page okay so to the index page now make sure that this index should be the same as this index for example if you have uppercase i then you need to just make it uppercase because it will not work and it will give you an error so return redirect URL for index okay now after doing that what we need we need to add this insert book and our model so if I go to the navword.html and I have showed you so we have something that's called form action okay now in here we can just add that and in this section I can just say so for example URL underscore 4. and I want to just use the insert insert I'm not model insert book sorry insert the book let's save it and let's refresh it so let's just add another book so for example Django you can just give an author and we can just give a price ad book so let's add it we have the data and if I check this table we have the Django and that's added so we have the title the author of The Price let's add another one for example python so the authors of example python and this is the price let's add and now the python is also added okay so now that's working and we can add the data in the previous lesson we have learned that how we can insert data now in the system we want to learn about Flash messages and flask so right now we can just add or insert data and there's no problem it will be added but what we want after inserting data we want to show a flash message in here for the user that for example the data is added so to do that we can use flask flash messages messages the first thing is that we need to open our app.pi file and in here we need to just import flash okay and after importing of The Flash so after inserting of the data and here uh after going to the index page we want to just say Flash not flash but Flash and we need to give this up for example the message okay so now we have this now what we want to do we want to show this flash messages in our index.html okay so that's the uh our index page and we want to show that and here at the top so in this section we also we will give a design for that so and here I can just say with messages and first we need to just say get flashed messages get flashed messages and we need to just end the width so I can just say end with and after that I want to check for example if messages and we need to just end this so if we have the messages so endf on that case we want to just go through the messages using for Loops or for a message and messages and we want to just end the four and here we can just show our message our flash message and let's create a div so div class now we can just use an alert bootstrap alert and we can just give a roll of alert uh after that and here we want to just show the message itself let's save it and let's try it so let me just give a AWS you can use the auto for example we can give the price like this and let's click on ADD book but before that we also need to add a secret key okay so if I just click on ADD book dep you can see that the session is unavailable because no secret key was set set the secret key on the application to something unique and secret okay so because we are redirecting and we're using a flash message you can see that the data is added and there's no problem but we haven't seen the flash message now to solve this problem we can just open our app.pi file and in here we can just add a unique secret key so I can just say app Dot secret key and for example something unique and I can just give it like this so let's just save it and now if I just click on ADD and let me just say testing um test 40 add and now the book added we have a nice flash message and also the data is added in this lesson we want to learn about updating basically we will create our update model in this lesson and in the next lesson we will work on updating functionality foreign right now we have our just basic sample app for example when I want to click on update button I want to see a model where the populated data so to do that first you need to open our the index.html so in here we have our update on and delete buttons and before the end for Loop we want to create our model so I'm going to paste the code and don't worry I will add the complete core or the complete source code and the video description but let me just describe we already have talked about the models for the insert model so we have our model classes just basically a bootstrap class also you can use models from the getbooster.com and you can just make it according to your choice so you have the model title we have the model body we have a form action that you will need that for updating we have the title so also for the title we need to just use input type head in we need to give the name ID and then here we are going to give an a volume for that okay because we want to just populate the data and we want to populate according to the ID so I can just say book dot ID and then here we want to give a value of book so book dot title okay and we can just come down we have author and for the author we also need the author so I can just say book God author and also for the price we should give a volume book dot price dot price so now if I just save it and if I go here and if I click on update so we are not seeing anything in here and that's because because we also need to Target this model okay so we have created the model but we haven't used that model so let's just go at the bottom at the top and this is our button now in here we can just Target that so I can just say so data we can just give the toggle first and for the toggle I want it should be model and also we need the target so database Target and then here we are going to just give an ID for this so right now I don't have any ID and I can just say model edit and also you need to give the book dot ID okay like this so now after adding this now we can just use that in here so we can just use model edit uh and here so model edit and I can just say book.id so book dot ID let's save it and now let's refresh it and if I go to the update so we have the data in here and if I go to this one uh but uh also I should see the item here but it's working there's no problem uh we will fax that but now that's that's working and if I click on this one testing update so testing test 40. and if I just use the AWS so the title the author and the price and for example when I click on this I should see the ID at the bottom so to solve that in the ref you can just use for example we can just say update and we can use book.id so book dot ID let's save it and now you can see that at the bottom we have update ID3 two four and this is id5 and that's working and if I just use this flask or this flask flask John that's working with the Django that's also working in the previous lesson we have learned that how we can create our update model now this lesson we want to learn that how we can update our data so right now you can see that if I click on update button you can see that we have a model with a populated data now we want to work on updating the data so now the first thing is that we need to create another route so I can just open my app.pi file and then here we have insert book now let's just create another route for updating so you can just say adapt.trout and I can just say update so foreign and also the methods as I can just say post so now I can just say diff update and now first we want to check that if request Dot method is host in that case first we want to get this specific data and I can just say my data and book dot cutie dot get and we wanted to get the specific uh according to the specific ID so I can just say request.form.get and I can just pass it in here so after that now I can just say my data dot title and I can just make it to request dot form title my data dot author and I can just say request.forum and I can just say author uh also we have price on my data.price and I can just say request.4 and price okay and after that we need to just say DB dot session we need to just commit and at the end we also give a flash message that and also we want to just go to the index page after updating so we can use a return redirect to the URL force or url4 to the index page okay so now after that let's just open our index.html and after that we want to just go to the update model so this is our update model and we have a form action and in here I can just say url4 and I need to pass the update in here okay update function now let's just save it and let's check it that it is working so if I click on update and if I say for example flask update it and let's just update so update it and you can see that's updated and that's updated if I check my database so let me just go here and if I go to the book and you can see that's updated so for example we can just update this one so we can just say new book and we can just a new Authors or new author and we can just give a price to 30 and update and that's update it so new book new author and the price is also updated so like this you can work on updating functionality in the previous lesson we have learned about updating the data now in this lesson we want to work on the last scroll updation and that is deleting the data so now in here if you see we have a delete button now we want to just work on the deleting so let's first of all create our delete route so I can just say def delete and I want to delete according to the ID so I can just save my data for example and I need to just get the uh a specific book according to the ID so I can just say dot get and I can just pass ID and after that we can just say DB dot session dot delete and I want to delete my data and after doing that we need to just commit so db.session dot command also we want to give a flash message that our book is deleted also we want to just go to the home page so our index page return redirect url4 and index okay so now we need to just go to the index.html because we have the delete button in here and in this section uh also you want to just add an on click we want to just add a JavaScript confirmation in here so I can just say on click and then the on click I want to just return for example confirm and I can just say are you sure to delete are you sure to delete and after that in the ref and here we need to just use our big function so I can just say delete and we want to delete according to the book dot ID okay and after that let's just save it and let's just refresh it and now if I just click on the flask updated let's click on that or you should delete okay so we have received that requested URL not found and let's check that where is the problem also that's not deleted and so we have the delete in here book.id okay but an app.pi okay so we need to create our route I forgot to do that sorry for that and in this section so this is the delete route so delete and the methods and here also we need to give the kit like this get our post and now let's just save it and let's refresh it delete okay again we have method not allowed but why so a tab dot route okay so delete and we need to just pass ID okay because we are going to delete according to the ID so let's now do we take once more delete okay and now let's delete it and we have our flash message and we don't have that in here so if I delete this one delete okay and that's also deleted and that's not uh we now we have four uh data and if I check this you can see that now we have four data now delete is also working right now our simple web app is working as expected now we want to add some more of features or services from the AWS for example right now if you see we are using a mySQL database and we're using one server now we want to add Amazon RDS or Amazon relational database service features to our flask web app now first of all let's talk about the Amazon artist and after that we will go through the configuration so now if you see the documentation of AWS Amazon RDS setup operate and scale a relational database in the cloud with just a few clicks and if you see if you come down our Amazon relational database service or Amazon RDS as a collection of managed services that makes it simple to subtype operate on a scale databases in the cloud uh choose from the seven popular engines there are different engines and Amazon artist that you can use so we have Amazon Aurora with mySQL compatibility Amazon postgres compatibility we have MySQL itself Mario DB postgres Oracle and skill server uh we will use MySQL and also uh for example when you create your account uh now when you're using AWS Services you should have an account up an AWS and when you create an account uh there will be a free tier for one year now uh for the modern orders if you see if you just go to the free tier so you can see as part of the AWS free tier the Amazon or this feature helps new AWS customers get started with managed database service in the cloud for free and this is the free tier 750 hours of Amazon RDS and the single availability availability Zone and db.t2.micros this is the NS tense or if that's unavailable you can use t3.micro or t4.micro if that's not available uh usage running MySQL Mario DB and postgres databases each month and also 750 hours of Amazon RDS single availability Zoom instance usage running skill server and also you will receive 20 gigabyte of general purpose SSD DB storage and 20 gigabyte of backup storage for your automated database backups so now I already have my account in here so we you can just search all these in here so you can just search for the RDS or relational database service let's just click on that and we want to just create a relational database service so let's wait so now in here let's just click on create database and we want to just create our first database engine and Amazon RDS and you will see the setup and I will show you that how you can use the free tier and make sure that choose the free tier if you choose another for example another one then you will be I'll pay for that so now in here you can see that first we need to choose a database creation method and we want to just use with the standard create and after that you can see that these are the engine types we have Amazon Aurora MySQL Mario DB postgres now we want to choose the MySQL so you need to just select the MySQL and after that you need to just come down okay so this is the addition MySQL community and you don't need to touch anything in here this is the engine version now in here you need to choose the templates now because we're using free tier if you use production then you'll pay for that you'll be paid for that we want to choose free tier make sure that you choose free tier and you can see that when I choose free tier you can see that these options are adjustable because the availability and durability of options are available for the production level Okay so after that this is the DB instance identifier and we want to just give the name so for example flask DB for example we can just name it like this and after that this is the settings credential now this is the username so uh we want to just leave it as admin and also you need to give the password here so we want to just give the password and also confirm the password okay so after adding the password now you can see that this is the instance configuration right now we have just one and this is db.23.micro uh this is also available for the free tier but also you can just use the t2.micro now if the t2 and T3 is not available then you can use the T4 dot micro okay according to their documentation so you want to choose the just this t2.micro micro so you can see that we have one vcpus one gigabyte of RAM and after doing that this is the storage type and this we also we need to use the general proposition or gp2 because it comes under the free tier and you'll receive 200 Top gigabyte of allocated storage and I want to just change this to for example 10 okay not much and also if you want the auto scaling you can choose that but I don't want to enable the auto scaling for my database or from my DB engine I can just disable that and after that you can this is the VPS we want to just choose the default one and also because we want it to be publicly accessible we can just choose the public yes okay and also if you just come down you don't need to bring any changes in here like this and so our setup is done uh also now if you see an additional configuration we have the port that's 3306 and we don't want to change that and now you can see that the stimuli monthly cost you can see that we don't have any cost in here because we are choosing the free tier and we already have talked the free tier is available to you for 12 months each calendar month the feature will allow you to use the Amazon RDS resources listed below for free the same amount of RDS and single availability zoom and also 20 gigabyte of general purpose storage and also 20 gigabyte of automated backup storage okay after that so after adding this now we are going to just click on create database and it will take a little bit uh to database being created so right now if I just go here it's creating and let's just wait for this all right guys now the DB engine has been created and if I just click on this you will see that I have some information about the database and at the same time we want to check the connection so if I come down you can see that this is the summary and if I just come down so we have the connectivity and also we have the security groups now I have chosen the default Security Group and I haven't talked about this uh about the security group so when you for example create that there will be a default security group that will be created so let me just show you and let me just show this so you can see that it has chosen the default Security Group the default of VPS Security Group and in here we have two rules uh we have inbound rules and also outbound rules for incoming and outgoing traffic okay so now uh we can just go back to the Amazon RDS and and here we have that and let's just check the connection okay them so now we have a end point in here I can just choose this and I'm using MySQL workbench let's just test the connection and then here I can just say flask test and we can just add the hostname so that is this is the port and the username is admin and we are going to just add our password in here so I can just say password and let's click on OK after that click on OK and now let's just click on this so now in here if I say show databases and if I just check it so now you can see that we have a connection and we have some data in here now we have created Amazon RDS and in the next lesson we will do our configuration with flask our flask web app in the previous lesson we have talked about Amazon RDS and also we have created our MySQL DB instance now this lesson we want to add that to our flask web app so now the first thing is that we want to just create a database so in here I can just say create a database and if you remember that we had a database so if I just open this so this was our database name flask AWS we want to just create this one so you can just say uh flask AWS and let's just create that so that's created now if I say show database so show databases and if I run this so now you can see that I have flask AWS after that what we want to do we are going to just open our flash configuration so this is flask AWS this is MySQL now this is a domain so admin and then here we need to just give the password now the password is password okay uh after that we need to give the host and we can just grab that from here so this is the host I can just copy that I can just paste it in here and I think we are done with that so now what we need to do we need to just open a flask shell because we want to create our table uh and here so right now if I just say uh use so for example use uh flask AWS and let's just use this okay and if I say show tables and you'll see that I don't have any table in here so show tables and if I just run it so right now we don't have any table but we want to create our table so to create the table we need to just open flask shell so flask shell after that hit enter so now in here the first thing is that we need to import so from App import DB after that I can just say DB create underscore all hit enter so let's just wait okay so now let's create it um this now we have this class Book Table in our Amazon artist so now if I just say show tables and if I just run this you will see that now I have The Book Table in here now let's create it and right now we don't have any data uh now for example if I refresh this you'll see that now I'm not seeing any data in here because now we have a new database okay uh over the table so that's not we don't have anything let's just add a book so I can just say AWS I can just add the author and also I can just add the price for example like this ad book and let's wait so that's added but this time this is added to the Amazon artist let's just add another one for example flask you can just add an author in here and we can just add a price so like this add book and now we have id2 and let's add it so if I just go here so for example if I say uh select all from book and so now if I just run this and now you can see that we have to book with id192 the title the author so like this we have integrated Amazon obvious feature to our flask web app I have my flask project and that's working and there's no problem also have integrated Amazon RDS or relational database service to my flask project now this lesson I want to push my project to GitHub and after that I will talk about the deployment of our project to Amazon ec2 or elastic compute cloud now before pushing our project to the GitHub now I have brought some changes to the project not uh and the coding but I've just created a new directory at name of flask app and after that I have just copied the files and folders inside the flask app now what I want to do I want to just create a requirements.txt so make sure that you are inside the flask app and after that I can just say pip freeze rack environments dot txt okay and it will create a requirements.txt for us okay so now uh if I just check this so we have this in here and these are our libraries okay uh now after that uh so right now you can see that this is my project flask project I'm going to just create a new repo in the GitHub so I can just name it flask ec2 and I will add also this project uh you can get this project from the GitHub the source code and after that I can just say click on I can just click on create repository so now I need to just uh first I need to just init so I can just say get an ad and after that uh we can just Commit This and also we need to just say get Branch Main and also we need to just I use this comment and then we need to just push the project okay okay so now we are done if I just go here and if I check this so now you can see that we have our project and in the next lesson we will talk about deployment of our project to ec2 or elastic compute cloud so we have our flask project and it's working also we have integrated Amazon RDS or relational database service to our flask project now this lesson we want to talk about Amazon ec2 or elastic compute Cloud so first of all what is a C2 now Amazon elastic compute cloud or ec2 provides a scalable Computing capacity in the Amazon web service or AWS cloud Now using Amazon Ace 2 illuminates your need to invest in Hardware up front so you can develop and deploy applications faster you can use Amazon H2 to launch as many or as few virtual servers as you need configure security and networking and manage storage it allows you to launch computer sources on the AWS cloud and with Amazon Ace 2 you have the flexibility to choose the hardware resource you need you're in control of the operating system any app and any other software that will run on the instance uh also and I'm also needs to instance runs on a host machine within a specific AWS availability Zone typically Amazon is to in a senses are provide virtualized access to the underlying host machine resources using a combination of hardware and software components so now let's practically create an Eastern stands and also talk about some more Concepts and easy to so now from here you can just click on S2 or you can just search up and here these two and after that you can just click on this and now this is these two dashboards so right now I don't have it in the stands and now how we can launch and understand so I can just come down in here and you can see to get started launch on Amazon is to instance which as a virtual server in the cloud now easy to instance is a virtual server in the cloud so I'm going to just click on launch instance and I want to just launch an instance so now let's just wait and you can see that Amazon needs to allows you to create virtual machines or instances that turn on the AWS Cloud so the first thing is that you need to give this name for the instance or for we can say for the virtual server so for example I can just give it a AWS flask okay and after that so now in here it's important application and always image or Amazon machine image okay so now we need to choose one of them and uh now the first thing is that uh when the server first bought a boots it's requiring operating system or we can say OS and the configuration of the attached storage volumes uh now an Amazon machine image or also we can set Ami provides the template for the osm applications on the root volume of your instance Amis also provide a block device mapping that can specify additional volumes to mount when an instance launched AWS provides a variety of Amis paid Amis are available through the AWS Marketplace you can create your own Amis from and Amazon is to instance that you have previously customized or by importing your own virtual machine or VM images and each of these regions maintain its own listing of Amis and emis that you create are available only within the specific region unless you copy them to other regions so now if you see in here there are different options and for example we have Amazon Linux Mac OS Ubuntu Windows red hot now we are going to just use human too and also available Dimension that when you create an account there is a free tier of one year and you can see that in here Ubuntu Server 22 it's Fleet here later eligible and if I just click on this you can see that these two are free tier eligible that you can use okay so I'm going to just choose this one uh because we want it should be free and after that now this is the an instance type that for example if you're using the free tier then there will be t2.micro or if the t2 dot micro is not available uh then you can use the t3.micro that will be available for you okay so you can see even the t1.micro is available but I'm choosing the t2.micrates also free tier and also you can see that every instance type there is a CPU and also memory for that foreign key AWS retains the public key and it's your responsibility to store the private key securely if your specify animals needs to keep here when you launch the instance it up secures the sign in credentials as a part of Amazon is to instance provisioning process so now for example if you want to do SSH and like these stuffs uh you need to just create a keep here and it's good to create that you can use a keepier to securely connect your ns10s okay using this keep here you can connect your instance ensure that you have access the selected key here before before you launch the instance so I already have keep ears so for example my key new key I have created but for you you can just click on create new tpr and you need to give the name of the clip here after that choose this keep your type and the DOT pm and click on create it will be created and after that it will automatically be downloaded and you can just use that so I'm going to just use this my key so for the network setting up I'm not going to touch anything and also uh we have another thing in here so if I come down we have a security groups okay now the security groups act as a stateful firewall for your Amazon E2 instances when you define Security Group rules you specify the source or destination of the network traffic and addition up to the protocols and ports that you allow if you change the security group rules that change propagates to an instances associated with that security groups we have two we need to we can specify two rules and the security group so we have inbound rules and also outbound rules now then bound Security Group rules you can control the source protocol and ports of allowed Network traffic for example you could allow tsp connections that originate from the ip4 addresses of your home network so that you can administer at an Amazon Institute instance using SSH or we have also outbound rules it enables you to control destination protocols and ports of allowed Network traffic and security groups include a default outbound rules uh you don't need to create that that allows all outbound requests to all protocols and ports to all destinations uh now what we need to do so you can just choose one so from here if you have so I have one and also there will be a default one for you but we want to create a new one so we can just click on this now this will be the name launch wizard one and you can see that we want to allow SSH traffic from anywhere and also for example you can choose if you want https and also HTTP traffic from the internet now in here you can see that you can choose anywhere you can choose custom or you can choose your own IP address now if you choose this anywhere rules with Source this allow all IP addresses to access your instances so now this is the storage and we have eight gp2 now this is the free uh comes under the free tier so future eligible customers can get up of up to 30 gigabyte of ABS or elastic Block store general purpose SD or magnetic storage okay so we want to just leave it as it is okay and we don't need to touch anything the number of instances one and that's the t2.micro and after that let's just click on launch instance so let's just create a tool take a little bit to be launched and we need to just wait for this and it's going to be launched in a few moment and if I go to view all instances and it should be pending right now so you can see that this is pending it's terminated my before it was uh now this is pending and only we need to wait it should be running so let's refresh it so it's spending and you can see that we have the information about that that's the availability Zone and uh we have a security group name and also a key name so now you can see it's running and another different ways that you can connect that if I select this you'll see that we have a bunch of information about this for example we have the details like instance ID we have the public ip4 other as the private address and also we have a DNS ip4 DNS and then distance type is t2.micro and we have a bunch of information about this for example for the security if you see we have two rules uh we have three rules and bound rules that we already have added so we have 22.80 for HTTP and this is for SSH and this is for uh https so now uh there are different ways that you can connect for example up you can just select this in a stance and you can just click on connect okay now the first way is that you can choose this is to instance connect and you can easily connect that you can just click on this let's wait for this so now you can see that's connected now this was the first way now the second way is that as I've already mentioned that for that uh that's a SSH client now for example uh uh if you're using Mac then you can just easily use this but for Windows 10 or 11 also you can use this as such through the terminal for that I already have said that you should have the key so my key.pm so I already have that key and now uh I can just open the terminal uh also uh also uh so I have added this key in my download folder yeah so in the downloads I have that key now I can just copy this and after that I can just paste it after that hit enter so now I can just say yes so now we are connected in our Ubuntu and like this you can connect that in the previous lesson we have created our Eastern instance now it's time to deploy our flask project to ec2 so right now I'm in Ubuntu server and the first thing is that we are going to just uh update so I can just say sudo apt uh get and I can just say update uh so it will take a little bit and after updating we need to just uh install Python 3 VNV uh let's wait and now we can just say sudo and I can just say uh opt get installed and I want to install Python 3 VNV okay like this so after installation now we have our project in the GitHub we need to just clone this project I can just copy this and in here I can just say get clone and I can just paste this in here okay after that hit enter okay so now uh for me uh now it uh now I have the if I CLS you will see that I have the project in here but for you it will require the username GitHub username and also password you can give your username but for the password you need to create a personal access token from your GitHub account the password will not work you need to add the token and after that it will work okay so now I have my flask ec2 now if I change directory to flask ec2 and if I say LS so we have our app.bi and we have our files in here so after that we need to just create a virtual environment or VNV and now let's wait and after doing that we need to just activate that okay so I can just say source and I can just say source V in V and pin activate foreign also we need to install G unicorn so pep install G unicorn like this and also that's also installed so now after that because we are using a mySQL database and MySQL client now we need to install some libraries and I need to just install this let me just copy this and let me just paste it in here hit enter and I can just say yes and also after that we can just install our requirements.txt so I already have installed G unicorn and I will not install that again but I need to install the uh requirements.txt let me just paste this okay now it will be installed after that I already have installed the G unicorn and now what we need to do uh uh so now we need to create a service for the G unicorn and we can just use systemd to manage uh the G unicorn now I can just copy this and let me just paste that in here and hit enter so now it is a nano editor and then here we need to just copy this code okay so this one okay so let me paste it in here and also make sure that you can see that in here I have changed the project to the flask ec2 because that's my project name and uh my directory name it should be in here and also you need to change this to your project or directory name okay flask these two flask is to I've given it like this but you can just give it whatever you want after that let's just save it so you can just hit Ctrl o hit enter and control X to exit from here and after doing that what we need to do we need to just reload so like this and after reload we need to just start and after doing that we need to just enable that oh so in here we have a problem in here because that is flask ec2 I have given flask so yeah that's flask ec2 so like this so let me just do that so flask ec2 flashy for use flask service every snow okay no problem uh no problem because we have already given this so we can just use it like this okay so now it has created that uh that's because because we have the flask ec.service okay sorry for that then now we that's not for the project that's for the service okay so now we have enabled that after that we need to just install nginx and after doing that we need to start that start nginx and after doing that we need to just enable that okay so now uh if I check uh my if I just go to the ec2 instance and let's just go to the ec2 instance running and if I choose this and if I just go to this public IP for address so let me just go here you can see that we have vulcam nginx and we have this Vulcan okay now after that now what we need we need to edit the default file and the sites available folder from the nginx because we want to point that to uh our flask project okay so now we can just use this and we can just paste it in here and it will open the Nano and in here we can just edit that so let's just go here come down and first of all uh in this section we want to just add this let's paste it and after that we need to just come down and we also need to bring change to the location so let me just come down and in here we have the location and let's remove this and I can just copy this and let's paste it in here okay uh No it should not be like this so let me remove this because we have the location so we have our the server and let's just come down also yeah we need to just remove this one also okay now uh I can just copy this from here because I have the location and I can just paste it in this section paste after that we can just say Ctrl o hit enter to save it and Ctrl X okay and after that we need to just restart that or start nginx and let me just paste it in here and hit enter okay so now uh let's just check it and now you can see that we have our flask project and and this this is our ip4 and now I can just add new book so ec2 instance author for example ec2 and we can just give a price ad book and you can see that is added and now for example uh I refresh it you can see I have that I can just update this so for example app dated update and you can see that's updated okay and in the back end we are using RDS and for example if I delete this let's okay and that's deleted and if I refresh this I don't have that in here in the previous lesson we have learned that how we can deploy our flask project to Amazon ec2 or elastic compute Cloud now in this lesson we want to talk about Route 53 and also we will learn that how we can add a custom domain name for our flask project so right now if you see this is our flask project that's deployed to ec2 and so if you see that AWS documentation for the Amazon Route 53 now a model Route 53 is a highly available in a scalable domain name system or DNS web service you can use rap53 to perform three main functions and any combination domain registration DNS routing and health checking now Route 53 is not a free service because uh for that you need to buy a domain name okay so if I just go to the Route 53 so Route 53 and I already have a domain name so you can see that scalable DNS and domain name registration I can just click on this and after that so now we can see that this is Route 53 dashboard and right now you can see that one I have one hosted Zone and also I have two domain that's registered so if you want to domain a buyer domain name from Route 53 you can just uh give your domain name and you can check that okay now it's not important that you should have domain name from Route 53 you can use another domain name from another company like GoDaddy but make sure that the domain name server should be the same as the hosted Zoom so if I just click on the hosted Zoom now for example if you want if you buy a domain name from Route 53 that there will be a default hosted Zoom for you so now you can see that this is the hostess Zone and that is for my this domain name that I have and as I will mention that if you have for example a domain name from another company like GoDaddy you can just find the for example the name server of the domain name to this post it soon okay so but if you want to buy a domain name from Route 53 there will be uh at the hosted Zone and you do need to bring any change also you can create your own hosted Zoom but make sure that you need to add the name servers to your domain name okay so right there you can see that we have to record in here and you can see that these are the name servers and this should match the name servers that I have for my domain name okay so now in here what I want to do so this is the domain name uh this is I want to create record okay so I can just click on create your card and right now you can see that this is our flask web application and then the record first I want to create a recording for WW and this is the record type I want to just use this one routes traffic to an ip4 address and from here I need to just copy this uh one this IP address and I can just paste it in here so I need to remove this HTTP and also this one okay so this is the first record and this is the TTL or time to leave I want to just leave it uh 300 again and for the routing policy we want to use Simple routing okay so after that I can just click on create records and it will create a better card for us so let's just wait so now the record has been created and you can see that this is the record for WWE if I copy this and if I just go here so let's just wait and also we need to create a let's just wait okay so now we can see that we have our home page and right now it's not secure but we will add a certificate and now you can see that it's working okay so now for example we can add another thing so I can just say route for example uh Route 53 and the authors for example AWS and we can just add price let's click on ADD let's add it and if I refresh this you can see we have that uh also we can for example update this of our updated and let's update and let's update it and I can delete this and that's deleted okay so also you can add another record for example it's for WWE we want to create another record for example for without ww okay and for that we also we are going to just uh not this one but we need the IP address so public ip4 address let me just copy this and let's paste that in here okay and let's just click on create a card so now it will be a record without WWE okay like this pathway is dot like it will be okay so now we can see that we have another record and that is created this is at the top uh for example if I just use this and for example let me just do that in here so if I add it like this and you can see that we have the same result and there is no problem okay right now you don't have ww but if I add for example uh WWE it is also working okay so because we have two records and they are working okay so if I just remove this and now and that's also working in the previous lesson we have learned that how we can uh deploy our flask project to ec2 and also we have learned that how we can add a custom uh domain name using uh route 53. now in this lesson we want to talk about about application would a load balancer and we will learn that how we can integrate that with our E2 instances so first of all what's an application load balancer now there are different types of load balancer that you can use uh but we are interested in ALB or application load balancer now elastic load balancing automatically distributes your encaming traffic across multiple targets such as these student instances containers and IP addresses and one or more availability zones all set monitors the health check of its registered targets for example maybe you will have three or four HT instances it will monitor the register the health of the register targets and also route traffics only to the healthy targets for example if you have a three or four Eastern instances maybe one is NLT then it will just uh for example uh route the traffic to the healthy targets also elastic load balancing a scale your scales your load balancer as your encanning traffic changes over time it can automatically scale to the vast majority of workloads okay and so you can see that there are different uh elastic load blasters that you can use application load balancer Network load balancer Gateway load balancer classic load blancer and a classic loot blancer is deprecated and also you can see that they have a good documentation and now we want to practically do this okay even though right now we have just one E2 instance but what we want to do we also want to secure our this web application right now you can see it's not secure the first thing that we want to do we want to create an application load balancer and after that we will talk about certificate of that how we can add that okay so now if you come down to these two instances you can see that we have a load balancers we can just click on this and we want to create a load balancer so we can just click on create load balancer and you can see that we have different types of load planter so now you can see that these are the load balancer type and this is the previous generation we are interested in alib or application load balancer it supports supports HTTP and https and choose an application load balancer when you need to uh flexible features set for your application with HTTP and https traffic okay so we are going to just click on create and after that uh so the first thing is that we need to give the load blancer name so for example I can just say flask uh load balancer now after that we need to choose a schema now a schema cannot be changed after the loot plans has created so this is for the public schema and this is for the private we want to use the public internet facing and for the for this we are using ip4 and we can just come down we want to just use the default VPS now these are the availability Zoom so I want to just choose all of them okay and it will automatically will have a subnet and let me choose this okay so after that we need to just use a security group so we have a default Security Group but we want to create a new one so let's just click on create Security Group so let me just say uh flask load security for example SG we can just say and for example allow HTTP and https traffic for this now let's just add rules for example we want to just add one rule for the HTTP and anywhere and also we want to add another rule because we will add a https also and 443 and let's just choose this okay and after that we can just click on create Security Group so now that security group has been created flask load is G and if I just refresh this uh you will see that now I have that security group so flask load SG and we need to remove the default so we want to just choose that and for right now we are using uh 1880 HTTP but we will do that now we need to just uh use a Target okay so we need to just create a Target group and a Target group we are going to add our Eastern stands that we have okay there is the instance that's deployed to the uh to the ac2 okay and then our flask project that's deployed to these two instance so now you need to choose a Target type you want to just use instances because we want to add that and you don't need to bring any changes to this and this is the health check and we can just click on next okay we need to give a name so flask for example uh Target okay and we can just click on next and from here we need to just add our list instance we have one and include spending maybe you will have more than that and after that we can just click on create that okay now it will be created the Target and after that we can just use that in our application load plancer so let's wait so now you can see the target group has been created and right now that's not associated now we can just refresh it and then here we want to just use this flask Target and after that we can just click on create load plaster so right now we don't we are not going to add any https listener we want to just use HTTP now we will load blancer and now if you see it will take a little bit uh let's just wait for this so right now we can see it is provisioning so now we can see that it's active and that's created if I just click on this and now uh so you can see that this is the uh DNS name so if I just copy this and let me just if I go here so you will see that I have my this flask application let's just wait so now you can see that we have our flask application now why we have used this because we want to add an SSL certificate for this then for that we need to add our Eastern instance to the load balancer and after that we can do that so now we can see that we have this and there's no problem we have the functionalities okay so in the next lesson we will talk about uh a Amazon certificate manager and also we are going to secure this okay so right now we have learned that how we can for example deploy our flask application to ec2 and we can for example add custom domain name and how we for example we can add our East instance to load balancers and in the next lesson we will talk about certificate manager in the previous lesson we have learned that how we can configure application load balancer now in this lesson we want to learn that how we can allow traffic to our load balancer so right now if you see uh we have our Route 53 and we have two records but right now if you see we are routing the traffic to the IP addresses now instead of that we have the load balancer so uh so this is the URL and also if I just go here this is the DNS name and we want to just load up around the traffic to this uh DNS name okay to our application load balancer now to do that what I want to do I'm going to just remove these two records uh these two and I can just delete these records like this okay and after that now I want to create another record in here and let me just click on create a card and from here uh I want to just use uh so now in here so this is the first one and then this section I want to just use Alias and from here I want to just choose for example Alias to application classic load Lancer we need to choose the region for example we want the uh we are in this region and our application load balancer is located in here okay and for the routing policy we want to use Simple routing now let's create record this is the first record and also you can create any other record for example for WWE if you want you can just click on this and after that you can just give www and after that we can just use Alias and we want to just use a list application and classic load balancer we need to just choose the region for example this region here and this is the loadable answer and let's just click on create records okay so now we have two records and you can see that now we are not pointing to the IP addresses of ec2 but we're pointing the traffic to our classic load balancer okay so now for example if I check this uh if I refresh this you'll see that I have the same result and if I for example give www dot and you will see that I have the same result and there is no problem and it is working right now we have our flask web application but it's not secure so in this lesson we want to talk about Amazon certificate manager or ACM and also we're going to learn that how we can secure our python flask web application so right there you can see that in here this is our flask web application and it's telling that your connection to the site is not secure now we want to just uh use of a aw certificate manager we want to request the certificate manager and after that we are going to uh just use that with our load balancer application load balancer now if you remember that when we have created our application load balancer we have just used Port ET and that's just for HTTP now we want to add another listener for the https or for the port 443 so now the first thing is that you need to just go to the certificate manager and from certificate aw certificate manager you need to request a certificate so you can see that uh the uh request a public certificate from Amazon or a private certificate for from your organization certificate Authority so we can just click on request certificate and from here we want to just request a public certificate you can just click on next you need to just add the fully uh qualified domain name for example we can just do it like this also you can add another domain name for example if you have subdomains uh you can also use that okay so for example wildcard Dot and I can just do it like this okay so now after this up we want the DNS validation for this for the validation method and this is the key algorithm and we don't need to add any tag to this you can just click on request okay so right now if you see this is our Route 53 and now right now if you see we have these records in here and now uh right now the validation is pending uh now it means that we need to create the records of the certificate to the Route 53 or hosted Zoom okay so now because uh if you don't have uh for example domain name from Route 53 you need to just use these records and you need to add that but I have the domain name from the Route 53 I can just create a card okay so I can just say create record and I can just click on create records okay so now it will create the records and after that this will be issued dependent by a pending validation now if I refresh this so let's just wait and also if you see in here let me just refresh this uh you can see that we have a new scene C name now this record is from the certificate and you can see now that's issued okay so now we have our certificate after that what we want to do you need to just go to the load blancer so load balancers and this is our load balancer that we have so if I just go to the load blasters uh this was the load balancers that we already have created so I can just click on flask load bronzer and if you come down for the listeners you can see that now I have just HTTP or DT now I want to add another listener in here and this should be for the https 443 after that we need to just add an action forward to and we want to just forward to the flask Target or to the to the Target group that we have and after that we need to just come down and we need to just add the certificate in here so from ECM or Amazon certificate manager and this is the certificate we have okay so if I refresh it this is the certificate A5 and if you check now this is the certificate A5 okay so now we can just choose that and after that we can just click on ADD and if I just go to the view listeners uh right now you will see that now I have two listeners so if I just go to the flask load bronzer and if I come down now I have two listeners one for the HTTP and another for the https okay so for example now if I just go here if I just say https for example https and if I do it like this okay so now you can see that it's secure okay and we don't have any problem for this thank you and also you can do it for the WWE so www dot and you can see that we have the same result and that is secure okay so for example you can add another one and I can just say SSL for example you can just add the Altar and we can just add the price so like this you can just add this and you can see that's added and if I refresh this let's add it also for example you can update this for example you can just click on update and for example updated and update and you can see that is updated and that is working and right now this is you can see connection is secure so like this you can create a simple flask application after that you can just integrate that with Amazon web services like a Amazon artists or relational database Service uh ec2 application load balancer and also for example we also we have used Route 53 and also we have used uh AWS certificate manager so thanks for watching of this video uh if you have any question please let me know and for the further videos please subscribe to my channel like the video and also share the video
Info
Channel: Parwiz Forogh
Views: 6,978
Rating: undefined out of 5
Keywords: AWS, Amazon Web Services, Python Applications, Deploy Python Applications to AWS, deploy python to aws, deploy, learn aws with python, aws and flask, aws with python applications, amazon web services with python, How to Deploy Python Applications to AWS (Amazon Web Services)
Id: DRWRq3ad0pI
Channel Id: undefined
Length: 118min 44sec (7124 seconds)
Published: Sat Dec 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.