AWS Logo
Menu
Claude Code on Amazon Bedrock: Quick Setup Guide

Claude Code on Amazon Bedrock: Quick Setup Guide

Configure Anthropic's AI Coding Assistant with AWS Bedrock

Jonathan Evans
Amazon Employee
Published Feb 25, 2025
Last Modified Jun 9, 2025
Hello AWS Community!
I'm excited to share how you can use Claude Code—Anthropic's agentic coding tool—directly with Amazon Bedrock, powered by the new Claude 4 series of models. Claude Code integrates into your terminal, understands your codebase, and assists with coding tasks through natural language commands.

What is Claude Code?

What is Claude Code? Claude Code is a powerful AI coding assistant that works both in your terminal and directly integrated with popular IDEs:
  • IDE Integration: Seamlessly integrates with VS Code, Cursor, Windsurf, and JetBrains IDEs (PyCharm, WebStorm, IntelliJ, GoLand)
  • Quick Access: Launch with Cmd+Esc (Mac) or Ctrl+Esc (Windows/Linux) directly from your editor
  • Smart Context: Automatically shares your current selection, open tabs, and diagnostic errors with Claude
  • Visual Diffs: View and apply code changes directly in your IDE's diff viewer
  • Core Capabilities: Edits files, fixes bugs, answers architecture questions, executes tests, resolves merge conflicts, and more
For detailed VS Code setup instructions, see Setting up Claude Code in VS Code.

Claude Code Models

Claude Code requires access to both a primary model and Claude 3.5 Haiku:
  • Primary model: Any Claude 3.7+ or Claude 4 model (Sonnet or Opus) that handles complex code understanding, generation, and reasoning tasks
    • Claude 3.7 Sonnet or higher recommended for optimal performance
    • Claude 4 models provide enhanced capabilities
    • Opus models offer the most powerful processing for complex challenges
  • Claude 3.5 Haiku: A lightweight model used for background functionality within Claude Code:
    • Generates small creative messages that appear while you type
    • Powers conversation summarization for the claude --resume feature
    • Handles various background processes with minimal token usage
    • Typically consumes under $0.04 per session for these background tasks
This dual-model approach optimizes both performance and cost - using the lightweight Haiku model where appropriate helps reduce overall token consumption while maintaining responsiveness.
⚠️ IMPORTANT ⚠️: You must explicitly enable access to both model types in your AWS Bedrock Model Access settings for the region you're using: (1) Primary model - Any Claude 3.7+ or Claude 4 model (Sonnet or Opus), and (2) Claude 3.5 Haiku - Required for background functionality. Failure to enable both a primary model AND Haiku will result in 403 Forbidden errors when using Claude Code. 🔑 🚫
See the AWS Bedrock Getting Started Guide for instructions on enabling model access.

Benefits of Using Claude Code with Amazon Bedrock

  • Leverage your existing AWS Bedrock allocation and billing
  • Access to Claude 4 Opus and Sonnet's advanced coding capabilities
  • Keep your code interactions within your AWS infrastructure
  • Maintain consistent security and compliance standards
  • Use of prompt caching for cost optimization (learn more about Claude Code prompt caching on Bedrock)

Before you begin

Check system requirements

  • Operating Systems: macOS 10.15+, Ubuntu 20.04+/Debian 10+, or Windows via WSL
  • Hardware: 4GB RAM minimum
  • Software:
    • Node.js 18+
    • git 2.23+ (optional)
    • GitHub or GitLab CLI for PR workflows (optional)
    • ripgrep (rg) for enhanced file search (optional)
  • Network: Internet connection required for authentication and AI processing

AWS Credentials Setup

Before getting started, ensure that your AWS credentials are properly configured. Claude Code will use these credentials to access Amazon Bedrock.
For detailed instructions on configuring AWS credentials, see:
https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html

Quick AWS Credential Setup:

  1. Using AWS CLI (easiest method):
    • Run aws configure
    • Enter your access key, secret key, default region (ensure you have Bedrock access in that region), and set output to json.
  2. Manual Configuration:
    • Create credential files in ~/.aws/credentials and ~/.aws/config
Remember, your IAM role/user must have permissions to access Amazon Bedrock and specifically the Claude models you're trying to use (your chosen Claude 3.7+ or Claude 4 primary model and Claude 3.5 Haiku).

Setting up Claude Code with Amazon Bedrock

Install Claude Code

Configure for Bedrock

Choose your primary model (pick ONE):

Option 1: Claude Opus 4 (most powerful - best for complex challenges)

Option 2: Claude Sonnet 4 (recommended - great balance of speed and capability)

Option 3: Claude Sonnet 3.7 (previous generation)

Launch Claude Code

Project Initialization with /init

Claude Code provides a helpful command to get started with a new project: /init

What /init Does:

  • Generates a comprehensive CLAUDE.md guide for your project
  • Creates documentation tailored to your specific codebase
  • Helps new team members understand the project structure
  • Provides a reference for working with Claude Code in your project

How to Use /init:

  1. Start Claude Code in your project directory with claude
  2. Type /init in the interactive REPL
  3. Claude will analyze your codebase and generate the guide
  4. Review the generated CLAUDE.md file
  5. Optionally commit the file to your repository with claude commit
The generated guide serves as a living document that explains your project's architecture, key components, and workflows - making it easier for anyone to understand and contribute to your codebase.

Accepting and Reviewing Code Additions from Claude Code

When Claude Code suggests code changes or additions, it's important to carefully review them before accepting:

Permission System

  • Claude Code uses a human in the loop permission system for safety
  • File modifications require explicit approval by default
  • You'll be prompted to confirm before changes are made

Best Practices for Code Review

  1. Carefully examine suggested changes before approving them
  2. Understand what the code does - ask Claude to explain if needed
  3. Check for edge cases that might not have been considered
  4. Verify security implications of any code that handles sensitive data
  5. Test the changes after they're applied to ensure they work as expected

Managing Context with the /compact Command

The /compact command is a powerful tool for managing context and maintaining efficient conversations with Claude Code:
  • What it does: Summarizes your conversation history into a concise format
  • Benefits: Preserves essential information while reducing token count
  • When to use: After completing major tasks, when responses slow down, or before starting new subtasks
  • Token savings: Significantly reduces token usage, helping manage costs even with prompt caching
Using /compact regularly is a best practice for maintaining coherent and efficient interactions with Claude Code, especially for complex coding tasks that require extended conversations.

Monitoring Your Costs with Claude Code

Claude Code provides several ways to track your token usage and associated costs:
  • During a session: Use the /cost command to see current token usage and estimated costs
  • Session summary: View a cost summary automatically displayed when exiting Claude Code
  • Set spend limits: Configure spending thresholds through your account settings
Remember that costs can vary significantly based on codebase size, query complexity, number of files being analyzed, and conversation length.

Next Steps

Once configured, try a simple command like summarize this project to test your setup. You can also generate a project guide with the /init command.
For more advanced workflows, check out the Claude Code documentation.

Additional Resources and Continued Learning

Thank you for exploring how to set up Claude Code with Amazon Bedrock! To see these concepts in action through a practical example, I encourage you to check out our follow-up tutorial:
In this hands-on tutorial, we'll:
  • Build a complete calculator web application from scratch
  • Demonstrate Claude Code's capabilities for code generation and enhancement
  • Show how to add scientific calculator functions to an existing project
  • Explore best practices for working with AI coding assistants
  • Provide practical examples of context management with /compact
The tutorial includes all the commands and explanations you need to follow along, whether you prefer working directly in your terminal or through the accompanying Jupyter notebook in our GitHub repository.
This practical walkthrough complements the setup guide you've just read and will help you develop an intuitive understanding of how Claude Code can enhance your development workflow with Amazon Bedrock.
Happy coding!

Note: Claude Code is now generally available. Usage costs will depend on your Amazon Bedrock pricing for Claude models. Remember to monitor token usage closely
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

20 Comments