Generative AI - AWS CodeWhisperer and AWS CDK - Hand On Demo. Build AWS S3, VPC and RDS.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] instructor there's been a lot of Buzz around generative Ai and AWS recently launched a new service called as AWS core whisper which is a generative AI coding tool which can generate anything from few lines of code to entire blocks of code based on the text prompt and contextual situation of the code in this video I'm going to show you how to use a cdk and code Spirit to create an S3 bucket VPC and RDS instance I was really amazed at the kind of suggestions that code Whisperer could provide let me know what you think of code respirator after watching this video in the comments below this video is also part of my address cdk course on udomi which you can check from the link in the description now let's go ahead and check the demo in this section we are going to discuss about AWS code whisper a generative AI tool powered by a large language model or llm AWS code whisper is an AI coding tool which can help you improve developer productivity by generating code recommendations based on their comment in natural language so code Whisperer is powered by large language model that is trained on billions of lines of code and as a result has learned how to write code in 15 programming languages so there's also case study if you see from the below link which talks about how Accenture reduced its development effort by 30 percent by using the Amazon code whisperer now let's see what we're going to build using AWS core whisper and cdk the first thing we are going to do is we're going to start with something really simple Amazon S3 so once we create the S3 bucket we are going to create an Amazon RDS but for creating the Amazon RDS we need to create the virtual private club so we'll first create the Amazon S3 bucket then we're going to create a VPC and then finally we're going to deploy an Amazon RDS instance in the VPC hope that's clear okay now let's go ahead and build some Hands-On so I'm going to use the summary of steps to create the resources so first I'm going to open the folder in the visual studio code editor and open the terminal then I'm going to create a directory using mkdr Code whisper and then I'm going to change directory into code whisper and then I'm going to initialize the cdk app and then in the subsequent steps we'll use the code Whisperer for code generation you can see I have a blank demo folder here that I'm going to open in the visual studio code editor next I'm going to create a code spread directory it will go clear and let's say change directory to code Whisperer okay now let me initialize the cdk app so let me go here okay now let me initialize the app so I'll say cdk in it minus minus curve I'm going to just pause the video till this is complete okay it's all done now let me do a clear now let's take a look at what AWS saves so you need to keep in mind these four different commands the first one is tab I'm using a Windows machine when the code Whisperer provides you some suggestions you have the option to either reject it or accept it if you want to accept the code solution then you have to click on the tab button on your keyboard if you want to reject it then you can hit Escape or continue typing now it will provide you various suggestion so you may want to include one or check what is the next one or go back to the previous one then you can use the left or right arrow on your keyboard and then finally sometimes it might not provide you suggestions and if you want it to provide suggestions then on the Windows you have to press alt C and the Mac option C okay now let's see this in action now let me just open the lib folder okay so it already has some boilerplate code I'm going to remove that boilerplate code and I'll just removed from here as well okay so the first thing we are going to do is we're going to provide it some comments so it gets context on what we are trying to build so let's say create and S3 bucket and you can see as soon as I wrote create an S3 bucket it's already giving me some suggestions so it's saying bucket is equal to new cdk AWS S3 dot bucket okay so I'm going to accept that and to accept this code suggestion I have to press tab on the keyboard so I press that tab you can see this code has been added now I have to import the S3 construct before I can continue so let me just go there and say import and and you can see as soon as I press the spacebar it gave me a code suggestion which is saying import AWS S3 as S3 and we can do that but let's try something different so I'll say star and okay now let's continue to type and see what more suggestions it gives so I will say import Star as S3 and now you can see it's giving me the current suggestion we import the AWS S3 construct so I'll press the tab button on the keyboard to accept this suggestion okay now let's go and on the documentation and see what are the other attributes that we can add from S3 bucket so we'll type AWS cdks3 over here and let me just go to the documentation we can see all these attributes are possible maybe we can add bucket name so let me just go back and say bucket name and once I press on bucket name let's see if it provides some suggestions and you can see it's giving me the name of the bucket as code Whisperer bucket and just taken that contextual knowledge so I'll press Tab and accept this now let's see what other options we have so press enter and now we can see automatically it has given me some more suggestions on removal policy because that's the most common when you do a cdk destroy by default it does not destroy the S3 bucket so I'm going to accept that and let's see what else is there pressing Auto delete objects true because if there is an S3 bucket and you try and destroy it but if it has Optics then it's not going to delete unless you have this Auto delete objects as true okay I'm gonna accept this as well you can see the code Whisperer is providing me a lot of suggestions which are quite valuable and I don't have to go to the documentation and make the changes so now let's go ahead and deploy and see if it works okay just I think we need to add one more bracket here from the syntax perspective let me see if I press alt C and if code whisper is going to provide any suggestions so I'll say alt C on the keyboard I'm getting it's not drawing me any suggestions let me add a bracket here and I think everything looks good so let me run a cdk deploy so it's asking me if you if I want to deploy these changes I'll say yes so I just waited a few minutes and you can see now the stack is complete now if I go to the cloud formation you can save a stack and if I just go to resources you can see this bucket has been created you can see this bucket has been created and this is the same one that we had here so one thing I want to highlight with which I struggled for a few hours is that once I installed the code whisper my auto save here stopped working and when I did the cdk deploy it would not create this S3 bucket so make sure once you make the changes you do a save here and then do the cdk deployment otherwise it's not going to work okay now let's go ahead and create an RDS instance but for that we first need to create a virtual private cloud or VPC now let me just add the details here create a VPC and now let's see what code suggestion it provides so it's giving me the VPC is new cdk AWS ec2 dot VPC so we know that for creating the VPC we need to import ec2 module so this seems correct so now let me just click on the tab key to accept this suggestion now I also need to import the ec2 model so let me do that and you can see it's giving me that suggestion import Star as ec2 from address cdk lib so that's pretty cool let me just accept that using the tab key so if I go to documentation you can see the same let me just quick search AWS cdk VPC [Music] so you can see here in the documentation we have to import the VPC construct and for that we need AWS ec2 and that's the suggestion that code Whisperer provided me to import the ec2 construct okay now let's go ahead here and it had already provided me this suggestion to create a variable VPC now let's add some properties to this so the first suggestion it's providing me is use the NAT Gateway 0 which is good I don't want to incorrect any cost so I'll accept that using the app button from the keyboard now let's look at the next suggestion so you're saying Max AC 2az say if I want to change that I just press the right arrow button on my keyboard and it will make some changes or it will give you different suggestions I'll just ignore this subnet configuration and press on Escape let me just try some other things we could look at some other attributes say you can see here we have the VPC name maybe try and VPC name and let's see so I'll say VPC name and then it's going to give me some suggestions so it's saying I can use code whisper Dash VPC so I'm going to accept that using the tab button again from my keyboard so now let's look at next suggestion so it's saying cider block as slash 16 so maybe I'll press the right arrow button on my keyboard and see if there are any other suggestions okay so it's not giving any other suggestions so I'll just accept that and maybe the last one we'll take a look is saying subnet configuration I will just ignore that you know press the escape button on my keyboard now say I need different suggestion but it's not providing me right now so I will press alt C on the windows and you can see again it's giving me subnet configuration and I just press Escape if you are on Mac then you have to press option C for more suggestions if you are on Windows you just press alt C and I'll set keyboard shortcut if you want to accept the suggestion you have to press F navigate between the suggestions left and right arrow and if you want to just ignore then you press Escape so this looks pretty good now let me just close the brackets and then we should be good okay now the last thing you are going to do is we're going to create an audio instance so I will say create and RDS instance so it gets a prompt on what I'm trying to do okay so it's already giving me some suggestions that you can create a variable RDS and this is and just give you some more details so probably I will just accept that and I will just go and import the RDS here so if I go to the documentation let's take a look and it will give us some idea the suggestion that code whisper is providing is correct or not so I will say cdk RDS okay so the first thing we have to import is the AWS RDS module so let's go back and I will say import and you can see here it's already based on the comment I had provided here to create an RDS instance and the code suggestion that it had made here it's guess that this is what I'm looking at so I will accept this and press the tab button okay great so this is really great uh it's really helping me and now let's look at some of the attributes so I will look at the database instance here on the left and now let's look at the attributes so only mandatory one is the engine and the VPC the rest of them are all optional those are the two maybe I will use and I've used a database name so now let's go ahead and do that so we have you have to use the engine and VPC let's take a look at the engine what it describes okay so it's describing the kind of database engine you want to use whether you want to use a Maria DB or Echo SQL Server so it's created the RDS then it is using the logical ideas RDS and then it is giving the option of using MySQL so it's already covered this part which is a database engine the next thing that's mandate is VPC so so let's give you an error I'm not really sure let me just try this again I will just remove this and let's see why it is error okay so the first thing we are going to do is use the engine so we'll say engine and okay now it's giving me the suggestion to use RDS dot database instance engine dot MySQL so this is what we had imported the RDS from here and okay that's the suggestion it was giving me and it's using RDS and then database instance engine and this seems correct so I'll press Tab and accept that now the next key one is the VPC so you can see again it realizes the ones that mandate the VPC is a mandatory one so it's giving me that suggestion okay so I'll accept that okay I'll just change the name maybe it's called demo and I think it should be good okay now let's go ahead and provide our database name we have his name and it's already given a suggestion to name it as code whisper so tap okay I think these properties are enough for now just for the demonstration purpose so I will just close the brackets and I just need one more bracket here okay so this seems good we have pretty much everything we need so let me just go ahead and do a cdk deploy and see if this works so I'll just pause the video for a little bit till this is complete okay now you can see that the update is complete but when I go to the cloud formation stack I don't see any of these resources and I deliberately did this because I wanted to show you because I spent a lot of time in trying to figure out what's the reason and the reason is that it's not saving automatically after I install the code whisper I don't know if it's just with me or it's a issue in general so if I now just do a save Here and Now do a cdk dip file it's going to work so I'll just pause the video for a little bit okay I think it's giving me an error and the error you can see here it's saying that it was cdk VPC cider is depreciated and that's true if you go to the documentation it will show that this attribute the cider one is depreciated and we should not use it but the thing is that it actually prompted me so that's not a correct one though it's depreciated it shouldn't have so if I just remove this and I think it should work now so let me just here you see okay before so just pause the video for a little bit okay it's giving me an error again saying that there are no private subnets in this VPC ideally there should be but I'm not really sure so let's do that let's add a subnet configuration and excuse me that suggestion so let me press alt C and see what it says okay so again I'll press RC so it's not really giving me anything useful so if I just go back to documentation and let me go to the VPC and you can see this is how the subnet configuration is actually implemented so I will just copy this here subnet configuration so I am actually on the VPC page so you can see here now let me go back to my code editor and just paste it here okay so I've just you just need to get rid of this subnet configuration okay so now this is good you can see now we are creating three different subnets one public private with egress and private isolated okay so I'll get rid of this as well now we have to launch this artist instance in the private isolated so if I go back to the documentation and for database so now I'm on the documentation for database instance so if I look at the properties and search for VPC subnets so here we have the PC subnet and if I just click on the selection so this is how we can select the VPC subnet okay so I will just copy this or maybe I will just type it out and see what suggestions the code Whisperer provides us so and say subnet and let me do all C and see if code vessel provides any suggestions okay yeah so good so it's providing me some suggestion on what is the subnet type I should use and which is the private isolated so I'll press the tab button on my keyboard except this so this looks good now hopefully it will work okay just give me some syntax error I think I need a bracket here okay now it's gone so hopefully everything will work I will do a save here and it will work clear and then do a cdk Depot so I'll just pause the video for a little bit till this stack patient is complete so it's asking me there is going to be some security changes I'll say yes okay it's taken a long long time to create all these resources you can see 27 out of 31 have been created so I just waited more than a few minutes let me take a look at the cloud formation and you can see here we have the cloud formation stack if I just go to resources School site View so we have the bucket that we had created earlier and we have bucket policy so I'm not creating a RDS instance and I am roll ec2 Security Group VPC okay I think our VPC is already created let me just take a look okay great so we have the code Whisperer VPC and I and I think that's the name that code Whisperer had suggested code Whisperer Dash VPC okay so this is good then let me take a look at the RDS instance that's it so I think RDS instance is still being created you can see create in progress let's just go here so you can see the code as far as stack artist has been created and it's available now size mb5 launch and it's a engine MySQL I think that's what we had provided okay finally after 540 seconds I think it's completed that's almost nine minutes it took to create the entire stack okay if I just go back to confirmation and you can see the update is complete and if I just do a refresh we should have our final audio stack okay let me just search for the RDS instance so it's created a lot of services yeah you can see it here so RDS instance is go hopefully it should be complete by now so you can see now it's available here and if I just click on this um and the status is available and the class whoever M5 large and we had Ms SQL Community as the engine so yeah everything looks good so this is how you can use a code Whisperer for automated code generation to improve the productivity of a developer so overall I think it really helped there were a few misses in terms of suggesting The Cider block which has been depreciated and I'm not highlighting the subnet types but overall I think it's really improved the productivity so if you are following along don't forget to do a cdk destroy because the RDS instance that it creates by default is M5 large so you could incur some charges so don't forget to destroy the stack and delete the RDS instance in some scenarios it might give an error saying that the log group or the RDS instance does not exist and which is okay because you will be able to create the S3 bucket the VPC and the RDS instance so you can either add the log group or you can just ignore that error the whole point of the section is to show you how to use code whisper to improve the productivity and not really demonstrate the end-to-end use case hope this is useful thank you
Info
Channel: GenAI with Rahul Trisal
Views: 819
Rating: undefined out of 5
Keywords: aws, aws_codewhisperer, codewhisperer, awscodewhisperer, generative_ai, aws cdk, cdk, cloud development kit, artificial intelligence, Generative AI, aws_cdk, aws_s3, s3, aws vpc, vpc, aws rds, rds, aws generative ai, aws codewhisperer, aws codewhisperer vscode, aws codewhisperer demo, aws codewhisperer handson, aws codewhisperer aws cdk
Id: oaTk7GS8CAU
Channel Id: undefined
Length: 22min 3sec (1323 seconds)
Published: Tue Sep 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.