Introduction: Why I Needed This Setup
Like many developers working in enterprise environments, I found myself in a situation where I wanted to leverage AI-assisted coding through Claude Code in VS Code, but I needed to use AWS Bedrock instead of Anthropic’s direct API. The reasons were straightforward: I already had AWS infrastructure in place, and using Bedrock meant better compliance with our security policies, centralized billing, and integration with our existing AWS services.
What I thought would be a simple configuration turned into several hours of troubleshooting. Status messages like “thinking…”, “deliberating…”, and “coalescing…” would appear, but no actual responses came through. Error messages about “e is not iterable” filled my developer console, and I couldn’t figure out what was wrong.
This guide is the documentation I wish I had when I started. It’s based on my real experience, including all the mistakes I made and how I eventually got everything working.
Update History
- **v2.0 (February 2026):
- Models:** Updated for Claude Sonnet 4.6, Opus 4.6, and Haiku 4.5. Sonnet 4.5 has been deprecated.
- Configuration: Added per-model environment variables (
ANTHROPIC_DEFAULT_SONNET_MODEL,ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_HAIKU_MODEL) as the recommended approach. - AWS Bedrock: Updated model access flow — models are now auto-enabled by default. Added Anthropic First Time Use (FTU) form requirement. Added AWS Marketplace IAM permissions (
aws-marketplace:Subscribe,aws-marketplace:ViewSubscriptions). - Claude Code: Added notes on new features (CLAUDE.md, hooks, MCP servers, slash commands, standalone CLI).
- v1.0 (October 2025): Initial publication. Based on Claude Code Extension v2.0.14 with Claude Sonnet 4.5 on AWS Bedrock.
What You’ll Accomplish
By the end of this guide, you’ll have:
- Claude Code extension fully integrated with AWS Bedrock
- A working configuration that uses AWS inference profiles
- Per-model configuration so you can switch between Sonnet, Opus, and Haiku from the VS Code UI
- A troubleshooting framework for common issues
Prerequisites
Before you begin, ensure you have:
- Visual Studio Code installed (Download here)
- AWS CLI installed and configured (Installation guide)
- An AWS account with appropriate permissions (at minimum:
bedrock:InvokeModel,bedrock:ListFoundationModels,bedrock:ListInferenceProfiles, and AWS Marketplace permissions:aws-marketplace:Subscribe,aws-marketplace:ViewSubscriptions) - Access to AWS Bedrock in your chosen region
- Anthropic First Time Use (FTU) form completed — required once per AWS account (or once at the organization management account level) before using any Anthropic models
- The Claude Code extension installed in VS Code (Extension page)
Quick Start Summary — TL;DR
If you’re in a hurry, here’s the absolute minimum to get started:
- **Complete Anthropic First Time Use form **AWS Console -> Bedrock -> Model catalog -> Select any Anthropic model -> Complete the FTU use case form (one-time per account)
- **Get your inference profile ARN
**
aws bedrock list-inference-profiles — region eu-west-2 — profile YOUR_AWS_PROFILE_NAME
**3. Test AWS connection
**Create a request.json file with this content:
{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Hello"}]
}
Then run:
aws bedrock-runtime invoke-model \
--model-id YOUR_INFERENCE_PROFILE_ARN \
--body file://request.json \
--region eu-west-2 \
--profile YOUR_AWS_PROFILE_NAME \
--cli-binary-format raw-in-base64-out \
output.txt
4. Configure VS Code
{
"claudeCode.environmentVariables": [
{"name": "AWS_PROFILE", "value": "YOUR_AWS_PROFILE_NAME"},
{"name": "AWS_REGION", "value": "eu-west-2"},
{"name": "CLAUDE_CODE_USE_BEDROCK", "value": "1"},
{"name": "ANTHROPIC_DEFAULT_SONNET_MODEL", "value": "eu.anthropic.claude-sonnet-4-6"},
{"name": "ANTHROPIC_DEFAULT_OPUS_MODEL", "value": "eu.anthropic.claude-opus-4-6-v1"},
{"name": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "value": "eu.anthropic.claude-haiku-4-5-20251001-v1:0"}
],
"claudeCode.selectedModel": "sonnet"
}
5. Reload VS Code and test
- Cmd/Ctrl+Shift+P → “Developer: Reload Window”
- Open Claude Code → Type “say hello”
Part 1: Understanding and Setting Up AWS Bedrock
Why AWS Bedrock Instead of Direct API?
AWS Bedrock acts as a unified interface for foundation models, including Claude. For enterprise users, this provides:
- Compliance: Keep all AI interactions within your AWS environment
- Cost Management: Centralized billing and monitoring through AWS
- Security: Leverage existing AWS IAM policies and VPC configurations
- Integration: Connect with other AWS services (CloudWatch, Lambda, etc.)
Step 1: Enable Model Access in AWS Bedrock
What changed: As of late 2025, AWS Bedrock automatically enables access to all serverless foundation models by default. You no longer need to manually enable each model. However, Anthropic models have one extra requirement — you must complete a one-time First Time Use (FTU) form before invoking any Anthropic model.
Why this matters: Without completing the FTU form, your first API calls may temporarily succeed but will fail with a 403 error after the setup period (~15 minutes). The form only needs to be submitted once per AWS account, or once at the organization management account level (it’s then inherited by all member accounts).
**Prerequisites:
**Your IAM role must have AWS Marketplace permissions: aws-marketplace:Subscribe, aws-marketplace:Unsubscribe, and aws-marketplace:ViewSubscriptions. Your AWS account must also have a valid payment method configured.
To complete the FTU form:
- Log in to the AWS Console
- Navigate to AWS Bedrock service (search for “Bedrock” in the services search)
- Important: Select your desired region from the top-right dropdown (e.g.,
eu-west-2for London,us-east-1for North Virginia). Pick one region and use it everywhere — region mismatches are a top cause of setup failures. - In the left sidebar, click Model catalog
- Select any Anthropic model (e.g., Claude Sonnet 4.6)
- Complete the use case details form when prompted
- Access is granted immediately after the form is submitted
Programmatic alternative: You can also complete the FTU form via the AWS CLI using the PutUseCaseForModelAccess API command. See the model access documentation for details.
Expected outcome: After submitting the form, all Anthropic Claude models become available in your account across all regions where they’re supported.
Reference: AWS Bedrock Model Access Documentation
Step 2: Understanding Inference Profiles (This Was My First Stumbling Block)
My initial mistake: I tried using the direct model ID anthropic.claude-sonnet-4-6-v1:0 and kept getting errors about on-demand throughput not being supported.
What I learned: AWS Bedrock requires inference profiles for on-demand usage. An inference profile is a wrapper around the model that enables cross-region routing, load balancing, and throughput management.
Three types of inference profiles:
Option A: Geographic Cross-Region Profiles (Recommended for data residency)
These keep data processing within a specific geography (EU, US, APAC, etc.), ensuring compliance with data residency regulations. They route requests across regions within that geography for better availability at standard pricing.
Examples for Sonnet 4.6:
- EU:
eu.anthropic.claude-sonnet-4-6 - US:
us.anthropic.claude-sonnet-4-6 - APAC:
apac.anthropic.claude-sonnet-4-20250514-v1:0
Option B: Global Cross-Region Profiles (Recommended for performance and cost)
These route requests to any supported commercial AWS region worldwide, providing the highest throughput and approximately 10% cost savings over geographic profiles. Use these if you don’t have data residency requirements.
Examples:
global.anthropic.claude-sonnet-4-6global.anthropic.claude-opus-4-6-v1global.anthropic.claude-haiku-4-5-20251001-v1:0
Option C: Custom Application Inference Profiles
You can create custom profiles for cost tracking or specific routing configurations, but for most use cases, the pre-configured Geographic or Global profiles work perfectly.
| Feature | Geographic (`eu.*`, `us.*`) | Global (`global.*`) |
|----------------|------------------------------|-------------------------------|
| Data residency | Within geographic boundaries | Any commercial AWS Region |
| Throughput | Higher than single-region | Highest available |
| Cost | Standard pricing | ~10% savings |
| Best for | Compliance requirements | Performance and cost priority |
Reference: AWS Bedrock Inference Profiles Documentation
Step 3: Verify Your Inference Profiles
The profile IDs listed in Step 2 are pre-configured by AWS and should work out of the box. You can verify they’re available in your account with:
aws bedrock list-inference-profiles \
--region eu-west-2 \
--profile YOUR_AWS_PROFILE_NAME
Check that the profiles you plan to use show "status": "ACTIVE" in the output. This command is also useful for discovering new profiles when AWS adds support for newer models.
Step 4: Configure AWS Credentials
What we’re doing: Setting up AWS CLI credentials so Claude Code can authenticate with your AWS account.
If you haven’t configured AWS CLI yet:
aws configure --profile YOUR_AWS_PROFILE_NAME
You’ll be prompted for:
- AWS Access Key ID: Found in AWS Console → IAM → Users → Security Credentials
- AWS Secret Access Key: Generated when you create the access key (save it securely!)
- Default region: e.g.,
eu-west-2(should match where you enabled model access) - Output format:
json(recommended)
Verify your configuration works:
aws sts get-caller-identity --profile YOUR_AWS_PROFILE_NAME
Expected output:
{
"UserId": "AIDACKCEVSQ6C2EXAMPLE",
"Account": "ACCOUNT_ID",
"Arn": "arn:aws:iam::ACCOUNT_ID:user/YourUserName"
}
If this fails: Check your credentials file:
- Windows:
C:\Users\USERNAME\.aws\credentials - Mac/Linux:
~/.aws/credentials
Reference: AWS CLI Configuration Guide
Part 2: Testing AWS Bedrock Connection (Before Touching VS Code)
Why this step saved me hours: I initially jumped straight to configuring VS Code, which meant I was troubleshooting two things at once (AWS connection AND VS Code configuration). By testing the AWS connection separately first, I could confirm that part worked before moving on.
Create a Test Request File
The AWS Bedrock API expects requests in a specific JSON format that follows the Anthropic Messages API structure.
PowerShell users: Use Set-Content with -NoNewline to avoid encoding issues:
'{"anthropic_version":"bedrock-2023-05-31","max_tokens":1000,"messages":[{"role":"user","content":"Say hello"}]}' | Set-Content -Path request.json -NoNewline
For Bash/Terminal (Mac/Linux/WSL):
echo '{"anthropic_version":"bedrock-2023-05-31","max_tokens":1000,"messages":[{"role":"user","content":"Say hello"}]}' > request.json
Test the Bedrock API
For Bash (Mac/Linux):
aws bedrock-runtime invoke-model \
--model-id arn:aws:bedrock:eu-west-2:ACCOUNT_ID:inference-profile/eu.anthropic.claude-sonnet-4-6 \
--body file://request.json \
--region eu-west-2 \
--profile YOUR_AWS_PROFILE_NAME \
--cli-binary-format raw-in-base64-out \
output.txt
cat output.txt
PowerShell note: Replace \ with backticks ``` for line continuation, and use Get-Content output.txt instead of cat.
Breaking down the command:
--model-id: Your inference profile ARN or ID. For cross-region (system-defined) profiles, you can use either the full ARN (arn:aws:bedrock:eu-west-2:ACCOUNT_ID:inference-profile/eu.anthropic.claude-sonnet-4-6) or the short ID (eu.anthropic.claude-sonnet-4-6).--body file://request.json: Path to your request JSON file--region: Must match your inference profile region--profile: Your AWS CLI profile name--cli-binary-format raw-in-base64-out: Tells AWS CLI to accept raw JSON input (not base64)
Expected Successful Response
If everything is configured correctly, output.txt should contain:
{
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_01VkZqvjyFoEp74SF26xipxW",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 9,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 12
}
}
If you see an error here, stop! Don’t proceed to VS Code configuration until this works. See the Troubleshooting section below.
Reference: AWS Bedrock Runtime API Documentation
Part 3: Configuring VS Code Claude Code Extension (Where I Spent Most of My Time)
Step 1: Open VS Code Settings
- Open Visual Studio Code
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the command palette - Type:
Preferences: Open User Settings (JSON) - Press Enter
This opens your settings.json file, which might already have other VS Code configurations.
Step 2: Add Claude Code Configuration (THE CRITICAL PART)
Claude Code now supports per-model environment variables, which let you configure different inference profiles for each model tier. This is the recommended approach — you can switch between Sonnet, Opus, and Haiku directly from the VS Code UI, and each model automatically uses the correct inference profile.
Add this to your settings.json:
{
"claudeCode.environmentVariables": [
{
"name": "AWS_PROFILE",
"value": "YOUR_AWS_PROFILE_NAME"
},
{
"name": "AWS_REGION",
"value": "eu-west-2"
},
{
"name": "CLAUDE_CODE_USE_BEDROCK",
"value": "1"
},
{
"name": "ANTHROPIC_DEFAULT_SONNET_MODEL",
"value": "eu.anthropic.claude-sonnet-4-6"
},
{
"name": "ANTHROPIC_DEFAULT_OPUS_MODEL",
"value": "eu.anthropic.claude-opus-4-6-v1"
},
{
"name": "ANTHROPIC_DEFAULT_HAIKU_MODEL",
"value": "eu.anthropic.claude-haiku-4-5-20251001-v1:0"
}
],
"claudeCode.selectedModel": "sonnet"
}
Breaking down each setting:
- **
AWS_PROFIL**E: Your AWS CLI profile name (from Step 4 in Part 1). Must match exactly what's in your~/.aws/credentialsfile. - **
AWS_REGIO**N: The AWS region where you enabled model access. Must match your inference profile region. - **
CLAUDE_CODE_USE_BEDROC**K: Tells Claude Code to use Bedrock instead of Anthropic's direct API. Must be"1"(as a string, not a number). - **
ANTHROPIC_DEFAULT_SONNET_MODE**L: The inference profile ID for Sonnet. This is used when you select "sonnet" in the model switcher. - **
ANTHROPIC_DEFAULT_OPUS_MODE**L: The inference profile ID for Opus. - **
ANTHROPIC_DEFAULT_HAIKU_MODE**L: The inference profile ID for Haiku. - **
claudeCode.selectedMode**l: Which model tier to use by default. Set to"sonnet","opus", or"haiku".
Common Mistake — Wrong Format (This Cost Me Hours!)
My biggest mistake was using the wrong format for environmentVariables. Claude Code expects an array of objects with name and value keys. These formats do NOT work:
// WRONG: simple key-value object
"claudeCode.environmentVariables": {
"AWS_PROFILE": "my-profile",
"CLAUDE_CODE_USE_BEDROCK": "1"
}
// WRONG: array of strings
"claudeCode.environmentVariables": [
"AWS_PROFILE=my-profile",
"CLAUDE_CODE_USE_BEDROCK=1"
]
Using the wrong format causes a cryptic "e is not iterable" error in the developer console, and Claude Code shows endless "thinking..." messages without ever responding. If you see this, check that your environmentVariables starts with [ and each entry has both name and value keys.
Legacy Single-Model Configuration
If you’re on an older extension version that doesn’t support per-model variables, you can use the single BEDROCK_MODEL_ID variable instead:
{
"claudeCode.environmentVariables": [
{"name": "AWS_PROFILE", "value": "YOUR_AWS_PROFILE_NAME"},
{"name": "AWS_REGION", "value": "eu-west-2"},
{"name": "CLAUDE_CODE_USE_BEDROCK", "value": "1"},
{"name": "BEDROCK_MODEL_ID", "value": "arn:aws:bedrock:eu-west-2:ACCOUNT_ID:inference-profile/eu.anthropic.claude-sonnet-4-6"}
],
"claudeCode.selectedModel": "claude-sonnet-4-6"
}
Step 3: Save and Reload VS Code
After saving your settings.json:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type:
Developer: Reload Window - Press Enter
VS Code needs to restart the Claude Code extension to pick up the new environment variables. Simply saving the file isn’t enough.
Step 4: Test Claude Code
- Click the Claude icon in the VS Code sidebar
- Type a simple prompt:
say hello - Press Enter
What you should see: Status messages like “thinking…”, “deliberating…”, and “coalescing…” are normal — they mean Claude Code is communicating with Bedrock. After a few seconds, you should get an actual text response.
If you only see status messages without responses: Check the Developer Console (Help -> Toggle Developer Tools -> Console tab). The error message there will tell you what’s wrong — see the Troubleshooting section below.
Reference: Claude Code Documentation
Troubleshooting: Real Problems I Encountered (And How I Solved Them)
Issue 1: “Invocation of model ID with on-demand throughput isn’t supported”
The error message:
An error occurred (ValidationException) when calling the InvokeModel operation:
Invocation of model ID anthropic.claude-sonnet-4-6-v1:0 with on-demand
throughput isn't supported. Retry your request with the ID or ARN of an inference
profile that contains this model.
Root cause: AWS Bedrock requires inference profiles for on-demand usage. You cannot use the model ID directly.
Solution: Use an inference profile ARN instead of the direct model ID. See Part 1, Step 2 for details on inference profiles and Step 3 for how to find your ARN.
Issue 2: PowerShell JSON Errors (“Malformed input” / “Invalid base64”)
If you’re testing with PowerShell, you may encounter either of these errors:
Malformed input request, please reformat your input and try again.
Invalid base64: "{"anthropic_version":"bedrock-2023-05-31",...}"
Root causes: PowerShell handles JSON string escaping differently than Bash, and by default, AWS CLI expects the --body parameter to be base64-encoded.
Solution — both fixes at once:
- Always save your JSON to a file instead of using inline JSON:
'{"anthropic_version":"bedrock-2023-05-31","max_tokens":100,"messages":[{"role":"user","content":"Hello"}]}' | Set-Content -Path request.json -NoNewline
The -NoNewline parameter is important — it prevents PowerShell from adding an extra newline character that breaks parsing.
Always include the --cli-binary-format raw-in-base64-out flag, which tells AWS CLI to accept raw JSON input instead of expecting base64.
Issue 3: “e is not iterable” — Status Messages Only, No Responses
This was my biggest headache. Claude Code would show “thinking…”, “deliberating…”, “coalescing…”, and then nothing.
Root cause: Wrong format for environmentVariables in settings.json.
Solution: See the “Common Mistake” callout in Part 3, Step 2. The environmentVariables must be an array of objects with name and value keys — not a key-value object or an array of strings.
Debugging tip: Open Help -> Toggle Developer Tools -> Console tab. If you see "e is not iterable", the format is wrong.
Issue 4: Authentication Errors / Access Denied
Symptoms: Errors like “Access Denied”, “UnauthorizedException”, or “Could not verify AWS credentials”
Possible causes:
- AWS profile doesn’t exist:
# Check if your profile is configured
aws configure list --profile YOUR_AWS_PROFILE_NAME
2. Credentials file is missing or corrupted:
- Windows: Check
C:\Users\USERNAME\.aws\credentials - Mac/Linux: Check
~/.aws/credentials
Should look like:
[YOUR_AWS_PROFILE_NAME]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
3. IAM permissions are sufficient? Your user needs bedrock:InvokeModel, bedrock:ListFoundationModels, bedrock:ListInferenceProfiles, and for initial setup: aws-marketplace:Subscribe, aws-marketplace:ViewSubscriptions.
Check in AWS Console → IAM → Users → Your User → Permissions
4. Profile name matches exactly? The name in VS Code settings must match ~/.aws/credentials — check for typos, extra spaces, and case sensitivity.
Verification command:
# This should return your user info
aws sts get-caller-identity --profile YOUR_AWS_PROFILE_NAME
Issue 5: Region Mismatch Errors
Symptoms: Model not found, or “requested resource is not available in this region”
Root cause: Inconsistency between where you enabled model access and where you’re trying to use it.
- Inference Profile region prefix —
eu.profiles route through EU regions,us.through US regions. YourAWS_REGIONshould be in the same geography. - VS Code Settings — the
AWS_REGIONenvironment variable must be a region where Bedrock is available and matches your inference profile geography.
Solution: Pick one region and use it consistently everywhere.
Issue 6: Extension Updates Break Configuration
What happened: After updating Claude Code extension, my configuration stopped working.
Solution:
- Check the extension release notes for configuration changes
- Verify your
settings.jsonstill uses the correct format - Check extension logs: View -> Output -> “Claude Code”
- If needed, downgrade: Extensions -> Claude Code -> gear icon -> Install Another Version
Pro tip: Before updating, copy your working settings.json configuration somewhere safe.
Verification Checklist
Before reaching out for support, verify each of these items:
AWS Bedrock Setup
- AWS account has a valid payment method configured
- IAM role has Bedrock permissions (
bedrock:InvokeModel,bedrock:ListFoundationModels,bedrock:ListInferenceProfiles) - IAM role has AWS Marketplace permissions for initial setup (
aws-marketplace:Subscribe,aws-marketplace:ViewSubscriptions) - Anthropic First Time Use (FTU) form has been submitted for your account
- You’re using an inference profile ID, not a direct model ID
- The inference profile is in “ACTIVE” status (verify with
aws bedrock list-inference-profiles)
AWS CLI Testing
- AWS CLI is installed and available in your terminal
-
aws sts get-caller-identity --profile YOUR_PROFILEreturns your user info - You can successfully invoke the model using the CLI test (Part 2)
- The CLI test returns actual JSON response with Claude’s message
VS Code Configuration
- Claude Code extension is installed and up to date
-
settings.jsonuses the correct environment variables format (array of objects withname/value) -
AWS_PROFILEexactly matches the profile name in your~/.aws/credentialsfile -
AWS_REGIONmatches your inference profile geography (eu-west-2foreu.*profiles, etc.) -
CLAUDE_CODE_USE_BEDROCKis set to"1"(string, not number) - Per-model variables (
ANTHROPIC_DEFAULT_SONNET_MODEL, etc.) use valid inference profile IDs -
claudeCode.selectedModelis set to"sonnet","opus", or"haiku" - VS Code has been reloaded after making configuration changes (Ctrl+Shift+P -> “Developer: Reload Window”)
Debugging
- Check Claude Code output logs (View -> Output -> “Claude Code”)
- Check Developer Console for errors (Help -> Toggle Developer Tools)
- No “e is not iterable” errors in console (if present, fix the
environmentVariablesformat — see Part 3, Step 2) - No AWS authentication or 403 errors in logs (if present, verify FTU form and IAM permissions
Working Effectively with Claude Code
Cost Management
How Bedrock charges:
- Input tokens: Everything you send to Claude (your code, prompts, context)
- Output tokens: Everything Claude generates back
- Cache tokens: Bedrock supports prompt caching — repeated context (like system prompts or large files) can be cached, reducing input token costs on subsequent requests. You’ll see
cache_creation_input_tokensandcache_read_input_tokensin API responses.
Pricing varies by model and region. Sonnet is the most cost-effective for daily development work, Haiku is cheapest for simple tasks, and Opus is the most expensive. Check the AWS Bedrock pricing page for current rates.
Rough token estimates:
- 1 token ~ 4 characters of English text
- 1,000 tokens ~ 750 words (approximately 1.5–3 pages)
Keeping costs under control:
- Switch models to match the task — use
/modelin Claude Code to switch. Haiku for simple questions, Sonnet for daily work, Opus only for complex reasoning - Use Global inference profiles —
global.*profiles route across regions and offer ~10% cost savings over geographic profiles - Use
/compactregularly — compresses conversation context, reducing token usage in subsequent messages - Be specific with prompts — “Fix the null check in
parseConfig()on line 42" costs less than "review this entire file" - Use CLAUDE.md to focus context — project instructions in
CLAUDE.mdhelp Claude avoid reading irrelevant files - Set up AWS Budget alerts: AWS Console -> Billing -> Budgets. Create alerts at spending thresholds (e.g., $50, $100)
- Monitor in Cost Explorer: AWS Console -> Cost Explorer -> filter by “Bedrock” service
Reference: AWS Bedrock Pricing
Performance Tips
If responses take 30+ seconds or you hit “Context Window Exceeded” errors, try these:
- **Use
/compac**t— this is the first thing to try when context gets large. It compresses the conversation history, freeing up space and speeding up responses - Compaction (auto) — on Sonnet 4.6 and Opus 4.6, Bedrock can automatically summarize older context when approaching the window limit (beta feature)
- Be specific — “Fix the bug in line 45 of parser.js” is faster than “review this entire file”
- Start new conversations — clear context for unrelated tasks instead of continuing a long thread
- **Use
.claudeignor**e— similar to.gitignore, this prevents Claude from reading unnecessary files (e.g.,node_modules/, build artifacts, large data files) - Use Global or cross-region profiles —
global.*profiles automatically route to less-busy regions - Switch to Haiku for speed — use
/modelto switch to Haiku when you need fast responses for simple tasks - Break large tasks into smaller chunks — split big refactoring into focused steps
Best Practices
- Create a
CLAUDE.mdfile in your project root — this is the single most impactful practice. Add project-specific instructions: coding conventions, architecture notes, test commands, and files to focus on or avoid. Claude reads it automatically at the start of every conversation. - Use slash commands —
/modelto switch models,/compactto compress context,/helpto see all commands - Be explicit about scope: Say “Only modify src/utils/helper.js” to prevent unwanted changes
- Iterative refinement: Ask Claude to refine suggestions rather than starting over
- Provide patterns: Use “Please follow the pattern in [filename]” for consistent code style
- Review before accepting: Always review code changes before applying them
- Use hooks for automation — configure shell commands that run before/after Claude Code tool calls (e.g., auto-lint after file edits, auto-run tests after code changes)
Example workflow that works well:
You: "Look at src/utils/parser.js and explain what it does"
[Claude analyzes just that file]
You: "Now add error handling for null inputs"
[Claude provides specific changes]
You: "Add unit tests for those error cases"
[Claude generates tests]
You: /compact
[Context compressed — ready for the next task without starting over]
Security Considerations
- Never commit AWS credentials. Claude Code reads from
~/.aws/credentials— keep that file secure. - **Exclude sensitive files with
.claudeignore**. Add patterns for.env, credentials, API keys, and secrets so Claude never reads them. Works just like.gitignore:
# .claudeignore
.env*
**/secrets/
**/credentials*
*.pem
*.key
3. IAM least privilege. Give your AWS user only the Bedrock permissions it needs:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BedrockInvoke",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "arn:aws:bedrock:*:ACCOUNT_ID:inference-profile/*"
},
{
"Sid": "BedrockList",
"Effect": "Allow",
"Action": [
"bedrock:ListFoundationModels",
"bedrock:ListInferenceProfiles"
],
"Resource": "*"
},
{
"Sid": "MarketplaceSetup",
"Effect": "Allow",
"Action": [
"aws-marketplace:Subscribe",
"aws-marketplace:Unsubscribe",
"aws-marketplace:ViewSubscriptions"
],
"Resource": "*"
}
]
}
- Why three statements?
InvokeModelsupports resource-level permissions, so it can be scoped to inference profiles only.ListFoundationModelsandListInferenceProfilesare service-level list actions that requireResource: "*". The AWS Marketplace permissions are only needed for the initial model enablement (one-time) and can be removed after setup. - VPC endpoints: For extra security, configure Bedrock to use VPC endpoints (keeping traffic within AWS).
Reference: AWS Bedrock Security Best Practices
Advanced Configuration Options
Available Models
| Model | Geographic Profile (EU) | Global Profile | Best For |
|--------------------|------------------------------------------------|--------------------------------------------------|-----------------------------------------------|
| Claude Sonnet 4.6 | `eu.anthropic.claude-sonnet-4-6` | `global.anthropic.claude-sonnet-4-6` | Daily development work (recommended) |
| Claude Opus 4.6 | `eu.anthropic.claude-opus-4-6-v1` | `global.anthropic.claude-opus-4-6-v1` | Complex reasoning, architecture decisions |
| Claude Haiku 4.5 | `eu.anthropic.claude-haiku-4-5-20251001-v1:0` | `global.anthropic.claude-haiku-4-5-20251001-v1:0`| Simple tasks, quick questions |
For US regions, replace eu. with us. in the inference profile IDs.
To switch models, just change claudeCode.selectedModel to "sonnet", "opus", or "haiku". Each model automatically uses its corresponding ANTHROPIC_DEFAULT_*_MODEL inference profile.
Multiple AWS Profiles
If you work with multiple AWS accounts, you can create separate VS Code workspace settings:
- Create
.vscode/settings.jsonin your project root - Add Claude Code configuration specific to that project
- Workspace settings override user settings
This allows different projects to use different AWS accounts or regions.
Environment Variables Priority
Claude Code checks for environment variables in this order:
- VS Code
settings.json(what we configured) - System environment variables
.envfile in workspace root
If you prefer system-level configuration, you can set these environment variables in your OS instead of VS Code settings.
What’s New in Claude Code
Since this article was first published, Claude Code has gained significant features:
- CLAUDE.md files: Create a
CLAUDE.mdin your project root with instructions that Claude reads automatically — much more effective than relying on README files alone - Hooks: Shell commands that execute before/after Claude Code tool calls, useful for validation and automation
- MCP Servers: Extend Claude Code with external tools and data sources via the Model Context Protocol
- Slash commands: Built-in shortcuts like
/help,/compact(compress context), and/model(switch models) - Standalone CLI: Claude Code now works as a terminal tool too, not just a VS Code extension. See the CLI documentation for details.
Integrating with CI/CD
You can use AWS Bedrock programmatically in your CI/CD pipelines:
# Example GitHub Actions workflow
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: AI Review
run: |
# Your script that calls Bedrock API
python ai_review.py
Team Adoption
- Shared AWS account: Set up a team AWS account with Bedrock access
- Cost allocation tags: Tag resources by team/project for cost tracking
- Share this guide: It’s a good starting point for onboarding
- Internal best practices: Document what works for your codebase
My Final Thoughts
Getting Claude Code working with AWS Bedrock took me several hours of troubleshooting, but it was absolutely worth it. Here are the key lessons:
- Test AWS connectivity first — don’t try to debug VS Code and AWS at the same time
- The environment variables format is critical — it must be an array of objects with
nameandvalueproperties - Inference profiles are mandatory — you can’t use direct model IDs with on-demand throughput
- Developer Console is your friend — Help -> Toggle Developer Tools reveals errors that aren’t visible otherwise
- Use per-model configuration — it makes switching between Sonnet, Opus, and Haiku seamless
What I use Claude Code for now:
- Explaining unfamiliar codebases
- Writing unit tests
- Refactoring complex functions
- Debugging obscure errors
- Code reviews before committing
The key is finding the right balance — Claude Code is a powerful assistant, but you’re still the developer making the final decisions.
Keeping This Configuration Working
When things break:
- Check if AWS credentials are still valid
- Verify model access is still enabled in Bedrock
- Check for Claude Code extension updates (and review release notes)
- Review VS Code settings.json for format changes
- Test AWS CLI connection first — isolate the problem
Additional Resources
Official Documentation
- Claude Code Extension: https://docs.claude.com/en/docs/claude-code
- AWS Bedrock User Guide: https://docs.aws.amazon.com/bedrock/latest/userguide/
- AWS Bedrock API Reference: https://docs.aws.amazon.com/bedrock/latest/APIReference/
- Anthropic Messages API: https://docs.anthropic.com/en/api/messages
AWS Bedrock Specific
- Model Access: https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html
- Inference Profiles: https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html
- IAM Permissions: https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples.html
- Bedrock Pricing: https://aws.amazon.com/bedrock/pricing/
Getting Help
- Claude Support: https://support.claude.com
- AWS Support: https://console.aws.amazon.com/support/
- VS Code Issues: https://github.com/microsoft/vscode/issues
Acknowledgments
This guide was born out of frustration, trial and error, and eventual success. Special thanks to the readers who flagged updates in the comments — particularly the config key format change (claudeCode.*) and the per-model environment variables.
If this guide helped you, pay it forward — help the next developer struggling with their configuration!
Document Version: 2.0 Last Updated: February 2026 Author’s Setup: VS Code on Windows, AWS Bedrock in eu-west-2
Feedback? If you find errors or have suggestions to improve this guide, I’d love to hear them. The best documentation is the documentation that helps real developers solve real problems.
Comments
Loading comments…