Amazon CodeWhisperer For a Cloud Novice
When I began my cloud journey early this year (2023), my aim was and is still to be a Cloud Developer. Since I was totally new to cloud computing (and tech in general), learning how to code while leveraging AWS services became my next aim only after I obtained the AWS Cloud Practitioner and AWS Solutions Architect Associate certifications. I used this approach because I wanted to get a really good understanding of AWS in general and its various services and how I will interact with them as a future cloud developer.
One tool that is optimized for writing code for AWS services is CodeWhisperer which was launched by AWS in June 2022 but became generally available in April 2023. In simple terms, it is Generative AI that suggests from logical blocks of code to entire functions in your IDE ( integrated development environment) based on your comments ( which acts as the prompts/inputs) and existing code. This tool generates code that meets AWS best practices, scans your existing code for potential security issues and so much more. No worries, AWS has an introductory course “Introduction to Amazon CodeWhisperer” on AWS Educate to give a cloud novice like you a full understanding what this tool is capable of.
As someone from an accounting background who is learning to cloud, I’ll recommend the following approach for any novice who wants to use this tool;
1) Learn how to Code and Read code
This may sound obvious to some people but CodeWhisperer is only a coding companion and does not teach you how to code. The best scenario I can give here is this;
You are senior developer and you give a task to a junior developer (CodeWhisperer) to do. You will have to first have a clear picture of what the end goal is so that you will be able to understand and efficiently use the code that will be generated.
There are tons of websites out there on learning how to code and one of such sites is freeCodeCamp where you can learn how to code for free. CodeWhisperer supports 15+ programming languages so you have a plethora of languages you can choose to learn.
2) Installing the AWS IDE Toolkit
These AWS IDE Toolkits are plugins and extensions (small piece of software to be installed) that enables you to access AWS services from your IDE. Based on your preferred IDE, the installation process will differ as AWS has Toolkits for Visual Studio Code, Visual Studio and IDEs from JetBrains.
One thing that is common with all these IDEs is that after downloading the toolkit, you need to authenticate and connect with either your AWS Builder ID ( easiest route in my opinion) or IAM Identity Center credentials for you to have access to CodeWhisperer. You can create an AWS Builder ID here. The process of authentication using AWS Builder ID is equally different for Visual Studio Code, Visual Studio and JetBrains.
3) Learn the “Art” of Prompt Engineering
Installing the toolkit and having CodeWhisperer at your disposal is only half way through. You will need to learn prompt engineering because CodeWhisperer, as its common with other Generative AI tools, needs prompts (inputs) to generate the code you desire (output). The more descriptive your prompts, the more relevant the generated code will be. The prompts will be written in your IDE as comments depending on the programming language you are using.
“Foundations of Prompt Engineering” a free course on AWS Skill Builder can equip you with the necessary prompt engineering skillset.
Short DEMO
(i)
I recently started a free AWS Cloud Project Bootcamp by AWS Hero Andrew Brown and for our first demo, I’ll be using one of the homework challenges for WEEK 0 which is to create a new Budget in your account using the AWS CLI. I will be using CodeWhisperer to generate a function that creates a JSON object that will used in creating the AWS Budget and I’ll write the results to a new file named “cloud_budget.json”.
(ii)
For our second demo, we’ll be generating a JSON to create a CloudWatch alarm for Billing and also write the results to a new file “billing_alarm.json”. Also, the file will be used to create the alarm via the AWS CLI
Just to reiterate again that, you will have to refactor the generated code to suit your needs. For example in the “billing_alarm.json”, I will need to change the “AlarmActions” to a real SNS ARN
"AlarmActions": [
"arn:aws:sns:region:accountid:ALARM_TOPIC"
],
Finally, just to state that most of the free courses I used were part of Amazon’s “AI Ready” initiative which aims to provide free AI skills training to 2 million people by 2025. Read this article to know more about this initiative and also discover other free AI courses for technical and non-technical individuals.
HAPPY CODEWHISPERING :)