概述
Amazon Q Developer 是 AWS 的 AI 编程助手,前身为 CodeWhisperer。它提供代码补全、AI 聊天、安全扫描、代码转换等功能。Amazon Q 的特色是与 AWS 生态的深度集成,能推荐 AWS 最佳实践、识别安全问题、协助 AWS 资源管理。它支持多种 IDE 和编程语言,特别适合 AWS 用户。免费版每天提供 50 次聊天和无限补全。
安装
Amazon Q Developer 通过 IDE 插件安装。支持 VS Code、JetBrains、Visual Studio、Eclipse 等。安装后需要使用 AWS Builder ID 或 AWS IAM Identity Center 登录。
# VS Code installation
# 1. Open the extension store
# 2. Search for "Amazon Q"
# 3. Click install
# 4. Restart VS Code
# 5. Log in with AWS Builder ID
# JetBrains installation
# Settings -> Plugins -> Search for "Amazon Q"VS Code 配置
在 VS Code 中使用 Amazon Q 需要配置 AWS 凭证。可以使用 AWS Builder ID(免费)或 IAM Identity Center(企业)。配置完成后即可访问所有 Amazon Q 功能。
# Configure AWS credentials
# Method 1: Use AWS Builder ID
# Click "Sign in with AWS Builder ID" in the Amazon Q panel
# Method 2: Use IAM Identity Center
aws configure sso
# Configure SSO as prompted
# Method 3: Use access keys
aws configure
# Enter Access Key ID and Secret Access Key代码建议
Amazon Q 提供智能代码补全,支持单行、多行和整函数补全。它基于上下文和 AWS 最佳实践提供建议。尤其擅长 AWS SDK 调用,能推荐正确的 API 用法和参数。支持引用追踪,识别开源代码引用。
# Code completion example
# Input:
import boto3
s3 = boto3.client('s3')
# Amazon Q will suggest:
# response = s3.list_buckets()
# for bucket in response['Buckets']:
# print(bucket['Name'])聊天
Amazon Q Chat 提供对话式 AI 助手。你可以提问代码问题、AWS 服务问题、架构建议等。聊天能理解项目上下文,可引用当前文件。支持 AWS 文档搜索,提供准确的 AWS 信息。
# Use Chat
# Shortcut: Alt+Q
# Example conversations:
# "How to upload large files with S3?"
# "Explain what this Lambda function does"
# "How to optimize this DynamoDB query?"
# "Add CloudWatch monitoring for this API"安全扫描
Amazon Q 提供安全扫描功能,自动检测代码中的安全问题。支持 OWASP Top 10、CWE 等安全标准。扫描结果包括漏洞描述、严重程度和修复建议。这是 Amazon Q 的独特优势,帮助开发者编写更安全的代码。
# Run a security scan
# In the Amazon Q panel:
# 1. Click the "Scan" button
# 2. Select the scan scope (current file/project)
# 3. View scan results
# 4. Fix issues based on suggestions
# Or via command:
# Cmd+Shift+P -> "Amazon Q: Scan Code"代码转换
Amazon Q 支持代码转换,如 Java 版本升级和框架迁移。它可以自动将 Java 8 代码升级到 Java 17,或从 Spring Boot 2 迁移到 3。转换过程包括代码修改、依赖更新、测试验证等。这显著降低了升级的工作量。
# Code transformation example
# 1. Select "Transform" in the Amazon Q panel
# 2. Select the transformation type (e.g., Java 8 -> 17)
# 3. Select the project
# 4. Amazon Q analyzes and generates a transformation plan
# 5. Execute the transformation
# 6. Verify the resultsAWS 集成
Amazon Q 与 AWS 服务深度集成。它可以协助 AWS 资源管理、CloudFormation 模板编写、IAM 策略生成等。支持 AWS CLI 命令生成和错误诊断。对于 AWS 用户,Amazon Q 是提升效率的强大工具。
# AWS integration example
# Generate a CloudFormation template
# "Create an S3 bucket with versioning enabled"
# Amazon Q generates:
Resources:
MyBucket:
Type: AWS::S3::Bucket
Properties:
VersioningConfiguration:
Status: Enabled定价
Amazon Q Developer 提供免费版和 Pro 版。免费版:无限代码补全、每月 50 次聊天、安全扫描。Pro 版(每月 $19):无限聊天、更高限额、管理功能。企业版提供团队管理、SSO 等。AWS 用户可在 AWS 控制台直接订阅。
Configuration
Amazon Q Developer is configured through AWS authentication and the IDE extension. Sign in with AWS Builder ID (free) or IAM Identity Center (enterprise). The extension settings control code completion, chat, and security scanning. Code Transformation and AWS integration features are accessed from the Q panel.
# Authenticate
# Option A (free): AWS Builder ID -> click "Sign in with AWS Builder ID"
# Option B (enterprise): IAM Identity Center
aws configure sso
# Option C: access keys
aws configure
# VS Code settings
{
"amazonq.enableSuggestions": true,
"amazonq.enableChat": true,
"amazonq.referenceTracker": "log"
}
# Security scanning: Amazon Q panel -> Scan -> select scope
# Code transformation: Amazon Q panel -> Transform -> Java 8 -> 17, etc.The free tier includes unlimited completion and 50 chats/month; Pro ($19/month) raises limits.
FAQ
Common questions cover pricing, AWS integration, security scanning, model selection, and Code Transformation. Amazon Q is deeply integrated with AWS—it recommends correct SDK usage and generates CloudFormation. Security scanning detects OWASP Top 10 issues.
Q: Is there a free tier?
A: Yes—free tier includes unlimited code completion, 50 chats/month, and
security scanning. Pro ($19/month) raises limits and adds management.
Q: Do I need an AWS account?
A: You need AWS Builder ID (free) or an IAM Identity Center login; no
full AWS account is required for the free tier.
Q: What does security scanning detect?
A: OWASP Top 10 and CWE issues, with severity and fix suggestions; run it
from the Amazon Q panel.
Q: Can it transform legacy code?
A: Yes—Code Transformation upgrades Java 8 -> 17 and migrates Spring Boot
2 -> 3, including dependency updates and test validation.
Q: Is it only for AWS projects?
A: No—it works with any code, but it's strongest at AWS SDK calls,
CloudFormation, and IAM policy generation.For AWS-heavy projects, Amazon Q's SDK best-practice suggestions and security scanning are especially valuable.
Ready to try Amazon Q Developer?
Visit the official site for the latest version and full documentation.
Visit Amazon Q Developer