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 a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFront Service Delivery PartnerAmazon OpenSearch Service Delivery PartnerAWS DMS Service Delivery PartnerAWS Systems Manager Service Delivery PartnerAmazon RDS Service Delivery PartnerAWS CloudFormation Service Delivery PartnerAWS ConfigAmazon EMR and many more.

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!