EventGet 50% off your ticket to MongoDB.local NYC on May 2. Use code Web50!Learn more >>
MongoDB Developer
MongoDB
plus
Sign in to follow topics
MongoDB Developer Centerchevron-right
Developer Topicschevron-right
Productschevron-right
MongoDBchevron-right

Getting Started with MongoDB and AWS Codewhisperer

Shane McAllister3 min read • Published Nov 06, 2023 • Updated Apr 02, 2024
AWSAIMongoDBJavaScriptJavaPython
Facebook Icontwitter iconlinkedin icon
Rate this tutorial
star-empty
star-empty
star-empty
star-empty
star-empty
Introduction
Amazon CodeWhisperer is trained on billions of lines of code and can generate code suggestions — ranging from snippets to full functions — in real-time, based on your comments and existing code. AI code assistants have revolutionized developers’ coding experience, but what sets Amazon CodeWhisperer apart is that MongoDB has collaborated with the AWS Data Science team, enhancing its capabilities!
At MongoDB, we are always looking to enhance the developer experience, and we've fine-tuned the CodeWhisperer Foundational Models to deliver top-notch code suggestions — trained on, and tailored for, MongoDB. This gives developers of all levels the best possible experience when using CodeWhisperer for MongoDB functions.
This tutorial will help you get CodeWhisperer up and running in VS Code, but CodeWhisperer also works with a number of other IDEs, including IntelliJ IDEA, AWS Cloud9, AWS Lambda console, JupyterLab, and Amazon SageMaker Studio. On the Amazon CodeWhisperer site, you can find tutorials that demonstrate how to set up CodeWhisperer on different IDEs, as well as other documentation.
Note: CodeWhisperer allows users to start without an AWS account because usually, creating an AWS account requires a credit card. Currently, CodeWhisperer is free for individual users. So it’s super easy to get up and running.
Installing CodeWhisperer for VS Code
CodeWhisperer doesn’t have its own VS Code extension. It is part of a larger extension for AWS services called AWS Toolkit. AWS Toolkit is available in the VS Code extensions store.
  1. Open VS Code and navigate to the extensions store (bottom icon on the left panel).
  2. Search for CodeWhisperer and it will show up as part of the AWS Toolkit. Searching for the AWS ToolKit Extension
  3. Once found, hit Install. Next, you’ll see the full AWS Toolkit Listing The AWS Toolkit full listing
  4. Once installed, you’ll need to authorize CodeWhisperer via a Builder ID to connect to your AWS developer account (or set up a new account if you don’t already have one). Authorise CodeWhisperer
Using CodeWhisperer
Navigating code suggestions
CodeWhisperer Running
With CodeWhisperer installed and running, as you enter your prompt or code, CodeWhisperer will offer inline code suggestions. If you want to keep the suggestion, use TAB to accept it. CodeWhisperer may provide multiple suggestions to choose from depending on your use case. To navigate between suggestions, use the left and right arrow keys to view them, and TAB to accept.
If you don’t like the suggestions you see, keep typing (or hit ESC). The suggestions will disappear, and CodeWhisperer will generate new ones at a later point based on the additional context.
Requesting suggestions manually
You can request suggestions at any time. Use Option-C on Mac or ALT-C on Windows. After you receive suggestions, use TAB to accept and arrow keys to navigate.
Getting the best recommendations
For best results, follow these practices.
  • Give CodeWhisperer something to work with. The more code your file contains, the more context CodeWhisperer has for generating recommendations.
  • Write descriptive comments in natural language — for example
Or
  • Specify the libraries you prefer at the start of your file by using import statements.
  • Use descriptive names for variables and functions
  • Break down complex tasks into simpler tasks
Provide feedback
As with all generative AI tools, they are forever learning and forever expanding their foundational knowledge base, and MongoDB is looking for feedback. If you are using Amazon CodeWhisperer in your MongoDB development, we’d love to hear from you.
We’ve created a special “codewhisperer” tag on our Developer Forums, and if you tag any post with this, it will be visible to our CodeWhisperer project team and we will get right on it to help and provide feedback. If you want to see what others are doing with CodeWhisperer on our forums, the tag search link will jump you straight into all the action.
We can’t wait to see your thoughts and impressions of MongoDB and Amazon CodeWhisperer together.

Facebook Icontwitter iconlinkedin icon
Rate this tutorial
star-empty
star-empty
star-empty
star-empty
star-empty
Related
Tutorial

Currency Analysis with Time Series Collections #1 — Generating Candlestick Charts Data


May 31, 2023 | 6 min read
Tutorial

How to Build a Go Web Application with Gin, MongoDB, and with the Help of AI


Sep 27, 2023 | 11 min read
Tutorial

Create a Java REST API with Quarkus and Eclipse JNoSQL for MongoDB


Jan 30, 2024 | 6 min read
Tutorial

Build a RESTful API with HapiJS and MongoDB


May 31, 2022 | 15 min read
Table of Contents
  • Introduction