How to Setup Amazon CodeWhisperer

Introduction

Build applications faster with automatic code recommendations based on the Code and comments in VS Code.

It comes in two flavors,

  1. Individual: Follow Steps 1 to Step 9 to setup.
  2. Professional: You must choose the IAM Identity Center profile with the region and follow the same steps as the Individual.

Amazon CodeWhisperer

Setup CodeWhisperer for Individual

Open Visual Studio Code, go to the Extension section, and Install AWS Toolkit.

Amazon CodeWhisperer

After installation, you can view code whisper in the AWS section.

Amazon CodeWhisperer

Expand Code Whisperer; you see the start option and Click Start

CodeWhisperer, add the connection to AWS; here, you have to add your personal email to sign up with AWS Builder ID, select 2. Use a personal email to sign up and sign in with AWS Builder ID. This will redirect you to the AWS sign-up page.

Amazon CodeWhisperer

We will go with the second option to set up from scratch.

Step 1. At the prompt Copy Code for AWS Builder ID, choose Copy Code and Proceed.

Step 2. At the prompt Do you want Code to open the external website? Choose Open.

Step 3. A browser tab will open, displaying the Authorize request window.

The Code should have already been added to your copy/paste buffer. Paste it in and choose Next.

Step 4. A browser tab will open to the Create AWS Builder ID page.

Enter your email address and choose Next.

Step 5. A field for Your name will appear. Enter your name and choose Next.

Amazon CodeWhisperer

Step 6. AWS will send a confirmation code to the email address that you submitted.

On the email verification screen, enter the Code and choose Verify.

Amazon CodeWhisperer

Step 7. On the Choose your Password screen, enter a password, confirm it, and choose Create AWS Builder ID.

Amazon CodeWhisperer

Step 8. A browser tab will open with a message asking you to allow AWS Toolkit for Visual Studio Code to access your data.

Choose to Allow.

Amazon CodeWhisperer

Step 9. Return to VS Code. If you have already authenticated into other AWS tools using IAM, you will be asked whether you want to use Builder ID for all AWS services. Choose the option that best suits your situation.

Note. If you're not sure what to do, choose Yes, and keep using AWS Builder ID with CodeWhisperer while using.

Once you have completed these steps, CodeWhisperer will be activated, and you can start using it to generate code suggestions in Visual Studio Code.

How does it work?

Let's write a code to print and download a list of files from s3 Bucket.

Add new file as Test.py (.py for python extension)

Add a comment in the file "Write a program to print a list of s3 buckets file and download"

Amazon CodeWhisperer

If your codewhisperer should run like below.

Amazon CodeWhisperer

It will start writing a code line by line …. You must verify each line and Press Tab and Enter. It will print the next line for the Program.

Amazon CodeWhisperer

You can choose any supported language mentioned in the previous article.


Similar Articles