[00:02] in this video we're going to talk about a new AI code assistant called Amazon q that was just released recently now why is this a big deal well you guys probably already know and have been using AI code assistants already because [00:16] they are becoming pretty ubiquitous currently and the trend is going to continue even more in the next years and I believe AI code assistants in general are going to become huge and basically an essential part part of every [00:31] engineer's skill set and I myself as a devops and Cloud engineer use the AI code assistant mostly for writing infrastructure provisioning and configuration scripts and so on and I mostly work with AWS so I write [00:47] automation scripts for provisioning and configuring AWS infrastructure and its services now there are two most important questions related to the value important questions related to the value of AI code assistants or generative AI [01:03] tools like Amazon Q the first one is the quality of the output or the responses that it generates in our engineering use case it's the quality of code [01:16] suggestions or improvements troubleshooting and explanation of code troubleshooting and explanation of code that the tool generates so if I'm using that the tool generates so if I'm using a code assistant for working on AWS [01:28] Cloud platform then and the tool needs to have extensive knowledge and understanding of AWS Services the best practices of configuration the production best practices architecture elements of cloud infrastructure and so [01:41] on and probably the most important of all that data needs to be up todate because in Tech world you guys know how fast everything changes so there is really no value in getting an old version of configuration or outdated [01:57] code suggestions when writing automation scripts and in this case a huge benefit scripts and in this case a huge benefit of Amazon Q is that it's created by AWS itself so it has deep extensive knowledge of AWS Services configuration [02:12] architecture and so on and that can have a huge impact on the quality of output so in general an extremely important aspect of AI code assistant tools is how [02:24] much you can rely on the output it generates and the second question generates and the second question related to the value of such tools is the use cases they cover so what are those AI tools good for and why would [02:38] you want to use them in the first place can they actually help you 10x your speed and efficiency when working on complex devops or Cloud projects can they help you become a better engineer or are they not yet mature enough to [02:55] actually be of any help well that's exactly what we're going to see in practice in this video so make sure to stay till the end so how does Amazon Q actually work and how can it assist us or what tasks can it help us with when [03:10] we are working on a project as Engineers we can integrate Amazon Q in our code editor or IDE using a Plugin or extension and we can start using it [03:22] directly inside the ID so we can use it directly while writing the code or analyzing code without having to leave the ID and there is three main categories of tasks that Amazon Q can help us with the first one is [03:36] understanding the code or concepts themselves so for example if you are new to a project and the team has already written automation project that has been developing for multiple months or years there's going to be a huge code base [03:50] that you're going to have to understand for example you have a terraform project that Provisions AWS infrastructure with various different services like configures an eks cluster and integrates it with different AWS Services then [04:04] creates some I am roles and permissions create some kubernetes components so let's say there's a lot of things going on in the project and you need an easy way to understand that terraform code especially if you are a junior engineer [04:18] and your terraform knowledge is not as good you can use Amazon Q to help you understand the high level of the project or blocks of code as well as specific line LS of what they're configuring what they're provisioning and so on and you [04:33] they're provisioning and so on and you can use Amazon Q to learn and understand things that are not directly related to your code so maybe you want to have a your code so maybe you want to have a high level understanding of AWS services [04:46] or integration of multiple Services understand a certain architecture and so on so that's the first category of answers that you can get from Amazon Q which is explanation and understanding things the second one is Amazon Q [05:01] things the second one is Amazon Q actually generating code for you so let's say you're using a terraform module and you need to check the documentation to understand how to use that module what attributes that module [05:13] takes what values should be set for those attributes and so on so in this case you can describe what you want to write and let Amazon Q actually generate write and let Amazon Q actually generate that code for you so now in addition to [05:28] giving Amazon Q some kind of code to analyze it actually generates a code for some kind of new configuration or provisioning logic in the same category or code generation you can also use Amazon Q to adjust your existing code to [05:44] make improvements or to refactor the code maybe with a cleaner syntax or maybe extracting some values as parameters and so on and this is actually a feature I use quite often which is feeding an existing code that [06:00] works but making Improvement in the code and logic itself to cover the best practices for example and the last category of use cases that you can use Amazon Q for is troubleshooting and Analysis you're probably already used to [06:14] Analysis you're probably already used to it you spend 20% of your time writing the code writing the configuration and probably 80% of the time troubleshooting the issues if something goes wrong so troubleshooting is an important and very [06:28] troubleshooting is an important and very integral part of our job as Engineers so that's again something that AI code assistants like Amazon Q will help you with an example of that would be if you're getting errors in your output [06:41] sometimes those errors are not very self-explanatory so usually you would copy paste the error message and Google it and that will be a perfect use case of asking Amazon Q to actually analyze that issue for you explain to you what [06:54] that issue is and giving a suggestion on how to fix it so as you see there bunch of tasks and use cases that we have to do as engineers and now we're going to actually see some of those use cases in practice and how Amazon Q can help us in [07:11] practice and how Amazon Q can help us in those tasks and with that let's Dive Right into testing out and trying Amazon Q for an actual infrastructure automation project for AWS so I'm using visual studio code as my editor and I [07:26] have my very simple terap project that basically configures an eks cluster with its corresponding VPC so a basic configuration to keep things simple and [07:39] in order to use Amazon Q in my visual studio code I can simply install that as an extension so as you see it's an official plug-in from amazon.com and once you install that you're going to see this icon here or a tab for Amazon [07:55] que and if I click inside I see an option to sign in and then we're going to be able to use Amazon q and conveniently enough we have this very simple mode of being able to sign in without an NS account and also use it [08:10] for free as part of the free tier so I'm going to click here let's the authorization and as you see here you [08:25] can create a new AWS Builder ID or you can sign in to your existing one and I'm actually going to create a new one just to show you how it's going to look [08:46] code that you got on the email verify we set the password and there you go the Builder ID is created so now we can sign [09:13] in and you're going to be navigated to your profile [09:28] this will create the authentication so that we can use Amazon Q in our Visual Studio code editor which means if I go back we should see Amazon Q successfully back we should see Amazon Q successfully connected to your Builder ID account and [09:43] now it's ready to be used and what you see here this Amazon Q tab is a chat see here this Amazon Q tab is a chat window so chat is one way of interacting window so chat is one way of interacting with Amazon Q to ask it any questions [09:58] that you want so here is a place I mentioned you can use Amazon Q to analyze your code blocks your entire project to ask it any questions not directly related to code maybe to learn some new Concepts learn things about [10:12] different AWS services or even other Technologies find the right terraform module for your task and so on so this is a place where you can ask questions to Amazon q and the chat is what we're going to do for our project as well so [10:27] I'm going to close this and we can also create multiple chats to keep our questions separated so let's go ahead and start using Amazon Q for our terraform project to help us with some interesting tasks [10:42] so let me open my main terraform file that defines creation of eks and I'm going to ask Amazon Q to explain the [10:55] Q to explain the terraform project code for me in detail explanation of different parts of the code from eks creation to what variables [11:12] are defined for what so name and commence version which we have right here the manage node group all the cluster addons manage node group all the cluster addons and so on and also gives us a summary of [11:25] what this project is creating now let's actually ask Amazon Q to optimize or let's ask whether we should optimize anything in our [11:44] so first of all it gives us a little overview of the things that we have correctly done in the project so for example the usage of version with [11:56] the Tilt that helps us automatically update to the next minor version so Amazon Q is suggesting that it's a good practice as well as setting the create cluster Security Group to false and installing those default [12:12] add-ons in the cluster and it found some optimization opportunities some improvements that we can make it's suggesting to extract this VPC and subnet configuration so if we have other resources that we want to [12:28] create also the same VPC in addition to eks then we can reuse that VPC it also is telling us and this is actually quite a good suggestion to increase the instance type because T3 [12:44] micro is actually pretty small for lots of the services like if we were installing Ingress controller Argo City or or some databases this would probably be small for most of those services so [12:58] be small for most of those services so it suggesting to change it to a larger it suggesting to change it to a larger size and also add additional manage node size and also add additional manage node group and this is also a good one to [13:10] Output some values as a result of infrastructure creation for easy access like for example a command to connect to EAS cluster and get the cube config file [13:22] so now we can actually ask Amazon Q to generate code or give us code examples of all those Improvement suggestions so I'm going to ask it to give to give me [13:51] code and here is the part where Amazon Q generates code examples for you this is for extracting VPC and private subnets using larger instances the output file and so on now this brings me to another [14:07] usage of Amazon q that you probably are going to use much more for the generative code so if you want an AI code assistant to actually Autos suggest code blocks or code lines or refactor your code you would use that directly in [14:23] your editor so we have a chat here and then you have inline code suggestions so let's say we leave this manage node group with T3 micro so if we have any group with T3 micro so if we have any parts that can be scheduled on such a [14:38] those but in addition we're going to create another node group with larger instance type and let's let Amazon Q generate that code for us first of all [14:50] suggestion and you can toggle to see different versions and I'm going to write a comment here eks manage not group with T3 large instance [15:04] group with T3 large instance type and you can autocomplete with type and you can autocomplete with Tab and again we can also specify additional details in our description or comment of [15:18] what Amazon c will generate so let's say we want a node group with a specific name let's call it main with Max five desired [15:34] desired 2 and let's see what we get there you go and as you see we have these continuous inline C suggestions that we're getting so let's say if I was creating another resource let's say I want to use another [15:47] resource let's say I want to use another module Amazon Q is continuously trying to guess what configuration I want to add to my project and as you see it actually comes up with multiple suggestions which I can toggle so in [16:01] suggestions which I can toggle so in case I want e node group configuration case I want e node group configuration or E case fargate or it has blueprints Kus add-ons which is actually a module that lets you install a bunch of [16:15] services directly in the cluster just by enabling them so I'm going to take over configuration and adding text and let's do a quick [16:27] test here and let's make sure that The Source the version that we're getting is actually a new one or recent one and let check this on [16:45] 4.27 so this is the version that it gave us now let me use Chad one more time and I'm going to ask it to configure or enable cloud trail logs for my eks enable cloud trail logs for my eks cluster so let me ask Amazon Q how I can [17:00] cluster so let me ask Amazon Q how I can do [17:13] do that so first it suggests to create an i IM role that will have permission to write cloud trail logs to cloudwatch so that's the terraform configuration for the role which cloud trail service can assume then we have have the r [17:29] permissions themselves so that's the policy that allows creation and reading policy that allows creation and reading of the logs and log groups and then using this configuration this will enable cloud [17:45] trail logs on eks cluster now let's do one final question here on a project and I'm going to ask it to give me any additional terraform configuration for my e cluster based on security and production best practices and now let's [18:02] see what we get it is telling us to enable the comm's audit locks so that we have all the activity that's going on in the cluster captured in the locks in case we have a heck so we can do a security analysis it's also suggesting [18:18] us to enforce security policies on what pots can do so basically escalating any privilege within the Pod so that is a security configuration to make sure that cluster can only be talked to within the VPC the security [18:34] group configuration for the node groups the kubernetes node groups this is a good one enabling e has encryption to encrypt the itd data adding monitoring for cluster Health like Prometheus for example and so on so it's giving us some [18:48] example and so on so it's giving us some suggestions to improve security and basically make our eks cluster more production ready and one thing I want to note here is that Amazon Q actually provides the resources or references for [19:04] the answers it generates so basically tells you here's the answer and by the way I'm referencing these different resources so you can actually go and check and this is what I do most of the time when I get an AI generated answer I [19:19] usually validate I want to make sure I know which source this comes from whether it's an official documentation a Blog article what year it was written so how up to dat that resource is and so on so you can check that source and [19:35] basically get some additional context for whatever the reply was and you have that for most of the replies so for example here we know that this part is referenced in this resource and so on now let me show you another feature that [19:52] I personally find more interesting than the regular chat or inline code suggestions and that is the dev mode basically and as you see by the description what this Dev mode gives you is it increases your context for the [20:09] questions that you ask Amazon Q so Amazon Q can take your entire project as a context for answering your questions instead of just the files that are open in your editor but the thing that I find cool about this feature is that you can [20:24] actually use it to give you a very highlevel plan for complex tasks so if I want to configure something in my case cluster that's integrating with various Technologies and I have multiple steps to actually execute that I can ask [20:40] Amazon Q for a plan of how to actually do that complex thing so let's try this do that complex thing so let's try this out [21:10] for this Dev mode and the answer generation takes a little longer because one Amazon Q is using your entire project and second it is giving you a more detailed and thorough reply so let's see what we get so it's telling us [21:26] let's see what we get so it's telling us to enable Argus City in our main TF file using eks blueprints kubernetes add-ons so this is a module that as I mentioned allows you to toggle or basically very easily switch on different plugins and [21:42] one of them is Argus CD so that's how it's suggesting to install Aros CD which is fine it's even telling us to create a git repository that we can sync with Argo CD telling us to use customization files for kubernetes manifest and at the [21:58] end even add some automated testing so this is kind of a high level overview of what steps we can do let's try another example let's say I want to install and run vault in my cluster and I want to use AWS KMS service to generate and [22:15] store the encryption key for Vault and I'm going to ask Amazon Q for a plan of how to implement this with my terraform project so again I'm going to do Dev [22:41] with necessary permissions as always using a module to deploy volt that using a module to deploy volt that references that IM rooll The Vault [22:55] provisioning and now I'm actually I'm going to ask it to give me going to ask it to give me details and code Snippets for all the [23:07] details and code Snippets for all the steps in the configuration Snippets by creating the role that processes in the E cluster can [23:26] role that processes in the E cluster can assume volt module and so on now one thing that is clear is that you can't directly take this code and implement it because it's not going to work some of the steps are not fully [23:40] correct so when I'm using this feature what I'm getting the most value from is the highlevel road map sort of that points me into the right direction where points me into the right direction where I can then zoom in and either do [23:55] followup questions on Amazon Q or get the additional upto-date details from the documentation of different tools that I need so at this point Amazon Q is a tool that will help you finalize and create your configuration code or [24:11] create your configuration code or infrastructure code with iterations it's not going to do the entire programming and write the entire terraform project for you one more thing we can do in Dev mode is have Amazon Q generate the code [24:25] files for us when we ask Amazon Q to generate code it basically creates the contents in those files that you can take over in your existing file if you want to so if I click here it actually shows me this view that shows me kind of [24:39] a difference or addition in my existing file and if I want to insert the code I can do [24:53] this and it also created this ks. TF file and also updated the variables with file and also updated the variables with Vault version new task once I'm done with this one now I want to show you one final feature of [25:07] Amazon Q which is actually integrated directly into your AWS account so switching to the browser this is my AWS account and by the way you have Amazon Q as one of the services and right here you see the same icon that we had in our [25:24] editor this one right here and this is actually the integ integrated Amazon q and you can use it here to get insights to resources within your specific AWS [25:37] account which is actually very convenient if you're provisioning resources in multiple regions if you have let's say E2 instances running in different places if you have some other resources attached to those you can [25:52] resources attached to those you can actually query those resources directly here or you can use it just like your code assistant to ask it specific code assistant to ask it specific questions and get explanations or even [26:05] get some troubleshooting advice so for example I want to check how many E2 instances I have currently in the running state in this [26:22] have three instances running and it lists all those three instances with links so that I can jump into one of those let's do another one let's try [26:35] those let's do another one let's try listing all the subnets and it's giving me a list of all six subnets in this [26:50] us AWS commands for example so let's ask it what is it what is AWS CLI command for AWS CLI command for creating a new I am [27:07] as well as what parameters you can specify to that command and now let's give it additional details of what the role should be allowed to do and who can role should be allowed to do and who can assume [27:28] and there you go we have this create role with the name my role that I provided and the policy for ec2 instances to be able to assume this role and then we have the actual permission using the AWS [27:44] managed policy so this is another use case of using Amazon Q either here or of course directly in your IDE so this was a demonstration of Amazon Q AI code [27:57] assistant and some of its features and I hope I was able to demonstrate how it can be used some of the use cases so you get a full picture of how you can use it yourself in practice in your engineering projects and as always thank you for [28:12] projects and as always thank you for watching and see you in the next video