nSights Talks

Amazon CodeWhisperer

Tutorial Highlights & Transcript

00:00 - Amazon CloudWhisperer Preview
Good morning ladies and gentlemen. My name is Saad Lodhi and I am a DevOps engineer working with the layer two teams. The service name is CodeWhisperer. And it will be I foresee every DevOps engineer’s and cloud developer’s machine learning-powered AI coding companion.

A quick, different style of how we present before I start with the talking and the slides, let me show you a quick preview of why I came up with this demo. One of our clients in our call asked us to provide us with a sheet with all the public IPs of any instances that they have on their AWS account. I started to create a script, but then I tried to use this tool. Let me show you the entire process that took place to write that script. What I did was I added a comment and said, function to get all public IPs from EC2 instances. Then I just press my friend’s help button. I press it again. After a couple of quick seconds, while it gives me, it scours its own base, and I get a fully working function. I didn’t have to do a single thing. This is what really amazed me. This is a complete function, I just wrote a function to get a public IP. So it gave me a function. If I want, I can ask it to create an entire program and it scours its own library. It’s not even just AWS-specific. Let me just go and just say, function to convert a JSON to a CSV. Pretty generic. I’m going to wait for CodeWhisperer to help a brother out and give it five seconds. Yep, done. File, it picks up and checks it. This one is particularly using it from an S3 because it previously was in AWS. But you can fine-tune the comments and the suggestions you make to it. And it can provide you with accurate messages that you can use to then convert. Now that this little tasty preview is out of the way, let me go back to my slides and actually show you what I’m talking about.

02:41 - Virtual Assistants
I already showed you a quick magical preview of how this tool works. This is a virtual assistant and artificial intelligence, virtual assistants are everywhere, and getting help from artificial intelligence is not new. I’m from the older generation, some of you new folks might not even remember this guy, which was shipped, I think in the older versions of Microsoft Word. This was our first encounter with a virtual assistant where it would periodically look up the texts that you were typing and provide you with silly little tidbits and helpful hints like maybe the images that you’re trying to push into your texts are overlapping. Do you know how to do this? Tips and tricks like that. This was our first encounter with an artificial intelligence virtual assistant.

As tech got more advanced, we got more and more features. Siri is like the brand name child of a virtual assistant. I know personally that I have dedicated quite a bit of things that I used to do on my phone to just being a voice assistant. I think it’s been four or five years since I’ve set an alarm by hand. I just open up my phone, and I say OK, Google, it pops up with a small little ting. I say can you wake me up in five hours or three hours if you know I am heading a late night in and it will just simply put an alarm in for me? These features are getting more and more robust and starting to affect in the better way our daily lives.

04:39 - Virtual Assistants for Developers
There’s also an ongoing quest to have virtual assistants available for developers. Developers and software architects are the backbone of all modern architecture that is going forward and there’s been quite advancements in this. I think Code Pilot is one that was picking up steam quite a bit. I was interested in seeing if AWS was actually doing something. I think the start of the year was the first time I actually was busy with a massive script that I had to write. I was thinking man, it would be great to have something on the AWS side that can be our AI-backed, machine learning-backed, and just be a cool product from the AWS standpoint and really help out. Because we developers need all the help we can get with this kind of stuff that we’re asked to do, and AWS doesn’t make it easy with new services that keep coming out.
05:38 - AWS’s Option: CodeWhisperer
CodeWhisperer, just as I showed you is AWS’s option for a code assistant. It is, as I mentioned, a machine learning-backed, AI-powered code companion. You set it up on your AWS SDK toolkit, or I’m using it on the AWS toolkit on the VS code. What it does is it actually is backed by machine learning algorithms that have studied over a million public repositories and also AWS internal repositories. As you call it, it actually learns your coding behavior and helps you to increase productivity. It also has a lot of features like it can provide you with example codes that are available in the sole private repos from AWS or from other public AWS sources. It has a ton of features.
06:33 - Demo of CodeWhisperer
Let me go back to my screen and show you. I already showed you the coding suggestion part. When you do actually write code, it can provide you with suggestions on the go. It has the option to see how the flow of the code is going and then provide you with input so that it automatically fills out the code text that you’re doing, and put in the arguments. One of the other things that I saw, which was pretty cool, was since it’s built up the machine learning algorithms by breeding so many public repos, they also added a new feature. You can see here it’s called the run security scan, where if you have an actual code, I have this code available, I picked it up from a friend of mine who wrote it. I just wanted to get it from a demo perspective. I can just simply go and run a security scan and CodeWhisperer will then see what code is written and match everything based on it and compare it to its security best practices that are defined by the AWS team and the development teams. It will give you those suggestions. I ran this test before this demo, and it gave me like five. One was the Mail Chimp import was not available, which is an issue with my machine since I borrowed the script. One thing, which is an issue is the code was missing pagination. It says missing pagination and a paginated call can lead to inaccurate results, one must paginate to ensure additional results are not present before returning the results. It’s coming in on this user key IAM list access key. It’s a pretty good issue that CodeWhisperer has picked up where if you know there are multiple users on the account, then this code will only pick up the first thing that comes to this page later in the list. Whereas for more accurate results, this step needs to be paginated. You can use it both as your coding companion where it can provide you with helpful hints, and code suggestions for scored completions, and just use it to optimize and increase productivity. You can also use it as a separate security scan test to see the quality of your code, and whether there are any security risks with it.

It’s a pretty nifty feature. I haven’t used it a lot since I don’t do a lot of cloud development. But I got hooked up with this access code by a longtime friend of mine, and I only got my access keys three or four days ago. I have requested access to this for like upwards of a month and a half now. The access that I’m mentioning is that AWS CodeWhisperer is currently in a preview state. If you go to the AWS toolkit here and check on the development tools on the CodeWhisperer site, you won’t actually get this option. It asks for an access code. To get that access code, there’s a substantial waitlist. As I mentioned, it took me one and a half months to get this access code. So this feature is not publicly rolled out yet, probably because it’s in the testing phase and very early beta. But hopefully this feature should roll out pretty soon.

I’m interested to see what the pricing for this will be. But yeah, I’ve been using this sporadically for the past week and a half. I know one of my friends who is a cloud developer and works extensively with AWS API’s, SDKs and lambda API gateway, and all he does is cloud code on AWS. He sent me a gift basket this morning, just to say thanks for hooking me up. It’s increasing my productivity quite a lot. This is like a godsend. And he’s really appreciating this and based on his feedback, I’m just really excited to see what the future for this is.

Jasmeet Singh

Saad Lodhi

Senior Solutions Architect

nClouds

Saad joined nClouds in 2018 as a Senior Solutions Architect. He holds several AWS Certifications including Big Data - Specialty, Solution Architect - Associate, Developer - Associate, and Cloud Practitioner.