Using Amazon CodeWhisperer with AWS Lambda - CodeWhisperer

CodeWhisperer's features are becoming a part of Amazon Q Developer. Learn more

Using Amazon CodeWhisperer with AWS Lambda

This document describes how to set up and activate Amazon CodeWhisperer for the Lambda console. Once activated, CodeWhisperer can make code recommendations on demand in the Lambda code editor as you develop your function.

Note

In the Lambda console, CodeWhisperer only supports functions using the Python and Node.js runtimes.

AWS Identity and Access Management permissions for Lambda

For CodeWhisperer to provide recommendations in the Lambda console, you must enable the correct IAM permissions for either your IAM user or role. You must add the codewhisperer:GenerateRecommendations permission, as outlined in the sample IAM policy below:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "CodeWhispererPermissions", "Effect": "Allow", "Action": ["codewhisperer:GenerateRecommendations"], "Resource": "*" } ] }

It is best practice to use IAM policies to grant restrictive permissions to IAM principals. For details about working with IAM for AWS Cloud9, see Identity and access management in AWS Cloud9 in the AWS Cloud9 user guide.

Activating Amazon CodeWhisperer with Lambda

To activate CodeWhisperer in the Lambda console code editor, complete these steps.

Note

CodeWhisperer for Lambda is only supported in US East (N. Virginia).

  1. Open the Functions page of the Lambda console, and choose the function that you want to edit.

  2. In the code editor under Code source, choose Tools in the top menu bar.

  3. Choose CodeWhisperer code suggestions. This immediately activates the CodeWhisperer service, and a check mark appears next to this option. To deactivate, choose this option again.

For shortcut keys, see User actions.