AWS, Cloud Computing

4 Mins Read

How to set up Amazon CodeWhisperer with AWS Lambda to activate code recommendations.

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.  

 

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

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.

CodeWhisperer with AWS Lambda

Step 2: Click on “Change default execution role” and select a role to assign permission to access Amazon S3. Click on “Create Function” 

Amazon CodeWhisperer with AWS Lambda

Permission attached to IAM Role

Amazon CodeWhisperer with AWS Lambda 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. 

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

Amazon CodeWhisperer with AWS Lambda

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.  

 

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is an official AWS(Amazon Web Services) Advanced Consulting Partner and Training partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, AWS EKS Service Delivery Partner, and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best-in-industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

To get started, go through our Training page and Managed Services PackageCloudThat’s offerings

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.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!