Voiced by Amazon Polly |
Amazon CodeWhisperer
Amazon CodeWhisperer is a Machine learning-powered service trained on billions of lines of code. It generates code recommendations and helps to improve developers’ productivity. CodeWhisperer automatically generates code recommendations ranging from code snippets to full functions based on the comments and code written in natural languages.
Freedom Month Sale — Upgrade Your Skills, Save Big!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
Features of Amazon CodeWhisperer
- Get more done faster: It reduces the coding time and accelerates code-building tasks with unfamiliar APIs.
- Code with confidence: You can easily review and add attribution using CodeWhisperer based on the open-source projects repository URL and License.
- Enhance code security: It scans your code to detect vulnerabilities that are hard to find, such as those that don’t meet security or crypto library best practices that are hard to find, and gives you code recommendations to remediate them immediately.
- Use your favorite tools: CodeWhisperer supports code generation for 15 programming languages, and the accuracy and quality of code generated depend on the size and quality of training data. These languages include Python, JavaScript, TypeScript, C#, Ruby, Go, PHP, C++, C, Shell, Scala, Rust, Kotlin, and SQL.CodeWhisperer is available as an AWS toolkit extensions for interactive development environments (IDEs) like Amazon Sagemaker Studio, JupyterLab, Visual Studio Code, JetBrains, AWS Cloud9, AWS Lambda, and AWS Glue Studio.
This blog mainly focuses on how to set up Amazon CodeWhisperer with AWS Lambda and activate code recommendations, followed by one example.
AWS Lambda
Lambda is a serverless computing service that runs code in response to events without provisioning or managing servers. You just need to write your code and supply it to runtime that lambda supports. AWS Lambda runs your code on compute infrastructure and performs all management tasks like server and operating system maintenance, capacity provision, scaling, and logging.
AWS Lambda runs your code in response to the event, and you pay only for the compute time you consume to run the code.
Set up Amazon CodeWhisperer with AWS Lambda
Amazon CodeWhisperer can be integrated with AWS Lambda to get code recommendations for the comments and code written in the AWS Lambda function.
You can integrate Amazon CodeWhisperer with AWS Lambda using the following steps.
Step 1: Create a lambda function. Add Function Name and Runtime. Create a lambda function. Add Function Name and Runtime.
Step 2: Click on “Change default execution role” and select a role to assign permission to access Amazon S3. Click on “Create Function”
Permission attached to IAM Role
Step 3: Open the Function, go to “Tools,” and select “Amazon CodeWhisperer Code Suggestions.” This will activate the CodeWhisperer code recommendation for the AWS Lambda function.
Step 4: Another way to activate Amazon CodeWhisperer is to click on “+” and select “Preferences.”
Step 5: Go to “User Settings” and enable “Amazon CodeWhisperer Code Suggestions.”
Code Recommendation to create an S3 bucket in the AWS Lambda function
Here is an example lambda function to create an Amazon S3 bucket using Python code. Once you type the comment like “#import json python library” and click “Alt+c”, Amazon CodeWhisperer will generate a code recommendation, and you will able to add code to the Function
The below snippets will show the code recommendations generated by Amazon CodeWhisperer to create an Amazon S3 bucket.
Conclusion
Amazon CodeWhisperer service generates code recommendations using the comments and code written in natural language. It is a machine learning-based code generator service that helps to improve developers’ productivity. One can easily activate Amazon CodeWhisperer with AWS Lambda and get code recommendations.
Freedom Month Sale — Discounts That Set You Free!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

WRITTEN BY Rashmi D
Rashmi Dhumal is working as a Subject Matter Expert in AWS Team at CloudThat, India. Being a passionate trainer, “technofreak and a quick learner”, is what aptly describes her. She has an immense experience of 20+ years as a technical trainer, an academician, mentor, and active involvement in curriculum development. She trained many professionals and student graduates pan India.
Comments