<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arnab Patra on Medium]]></title>
        <description><![CDATA[Stories by Arnab Patra on Medium]]></description>
        <link>https://medium.com/@arnabpatra.dev?source=rss-9b3ec94d8379------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cZ8_lRaYxNTjVMPh</url>
            <title>Stories by Arnab Patra on Medium</title>
            <link>https://medium.com/@arnabpatra.dev?source=rss-9b3ec94d8379------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 00:23:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arnabpatra.dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Use Claude Code with Amazon Bedrock and Switch Between Anthropic API on a Mac]]></title>
            <link>https://medium.com/@arnabpatra.dev/how-to-use-claude-code-with-amazon-bedrock-and-switch-between-anthropic-api-on-a-mac-e2f6498a2723?source=rss-9b3ec94d8379------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2f6498a2723</guid>
            <category><![CDATA[aws-sso]]></category>
            <category><![CDATA[claude-api]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Arnab Patra]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 17:04:42 GMT</pubDate>
            <atom:updated>2026-04-25T17:10:31.359Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been playing with AI tools since the early ChatGPT days — not professionally at first, just out of curiosity. Side projects, personal automation, the usual tinkering. Claude Code eventually became my go-to for this kind of work at home.</p><p>When I opened a personal AWS account recently, it came with free credits. I figured I’d try routing Claude Code through Bedrock and use them up rather than continuing to pay Anthropic directly. Simple enough reason.</p><p>What followed was a few hours of credential errors, a 403 that made no sense, and a .env file situation I&#39;d rather not repeat. This post is what I wish existed before I started.</p><p>It covers:</p><ul><li>Setting up Claude Code with Amazon Bedrock using AWS SSO</li><li>Setting up Claude Code with the Anthropic API</li><li>Switching between the two without breaking your environment</li></ul><h3>Bedrock vs Anthropic API — which one should you use?</h3><p>Honestly, it depends on your situation.</p><p>Anthropic APIAmazon BedrockBest forPersonal projects, quick setupAWS environments, enterpriseAuthclaude.ai login or API keyAWS SSO / IAMBillingAnthropic invoiceAWS billData residencyAnthropic infrastructureYour AWS account</p><p>If you have AWS credits, an existing AWS setup, or work in an org that requires everything to stay within AWS — Bedrock makes sense. Otherwise the Anthropic API is less moving parts.</p><p>For my personal setup, I now run both depending on the project — Bedrock when I want to burn through AWS credits, Anthropic API when I want the latest model without thinking about IAM.</p><h3>Before you start</h3><ul><li>MacBook with Homebrew</li><li>Node.js — brew install node</li><li>AWS CLI — brew install awscli</li><li>An AWS account with Bedrock access</li><li>Claude.ai Pro or Max plan (only needed for the Anthropic API path)</li></ul><p>Install Claude Code:</p><pre>npm install -g @anthropic-ai/claude-code</pre><h3>Part 1 — Claude Code with Amazon Bedrock via AWS SSO</h3><h3>A note on credentials before anything else</h3><p>My first attempt used hardcoded AWS access keys in a .env file. It worked, until I had multiple projects with different AWS accounts and the wrong credentials kept leaking across sessions. Debugging that while also debugging Claude Code issues is not fun.</p><p>SSO solves this properly. <a href="https://medium.com/@swagattripathy/stop-hardcoding-aws-access-keys-youre-one-git-push-away-from-a-disaster-b8155af9c218">This post by Swagat Tripathy</a> explains the risk well — worth reading before you set anything up.</p><h3>Step 1 — Configure your SSO profile</h3><pre>aws configure sso --profile my-dev-profile</pre><p>Your ~/.aws/config will end up looking like this:</p><pre>[profile my-dev-profile]<br>sso_session = personal-sso<br>sso_account_id = &lt;your-account-id&gt;<br>sso_role_name = AdministratorAccess<br>region = us-east-1<br>output = json<br><br>[sso-session personal-sso]<br>sso_start_url = https://your-org.awsapps.com/start<br>sso_region = us-east-1<br>sso_registration_scopes = sso:account:access</pre><p>To find your SSO start URL: AWS Console → search <strong>IAM Identity Center</strong> → <strong>Settings</strong> → <strong>AWS access portal URL</strong>.</p><h3>Step 2 — Enable Anthropic models in Bedrock</h3><p>Go to the <a href="https://console.aws.amazon.com/bedrock">Amazon Bedrock Console</a> → <strong>Model catalog</strong> → find a Claude model → <strong>Request model access</strong> → submit the use case form. One sentence is enough, something like “AI-assisted software development.”</p><p>Approval is usually instant.</p><p><strong>Do not skip this.</strong> Bedrock now auto-enables most foundation models by default, but Anthropic models still require a one-time form. If you skip it, your first few API calls will actually succeed — then you’ll start hitting 403s about 15 minutes in with no obvious explanation. I lost a good chunk of time to this.</p><h3>Step 3 — Log in and verify credentials</h3><pre>aws sso login --profile my-dev-profile</pre><p>This opens a browser for SSO auth. Once done:</p><pre>aws sts get-caller-identity</pre><p>If you see your account ID and role ARN, your credentials are live. If this fails, your Claude Code calls will fail too — worth checking here before going further.</p><h3>Step 4 — Point Claude Code at Bedrock</h3><pre>export AWS_PROFILE=my-dev-profile<br>export CLAUDE_CODE_USE_BEDROCK=1<br>export AWS_REGION=us-east-1<br>claude</pre><p>Inside Claude Code, run /status. You want to see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kcDQsW2KkMREXNg-u-L-rA.png" /></figure><p>If it still shows your Anthropic API key or org name, the environment variable didn’t take — double check with echo $CLAUDE_CODE_USE_BEDROCK before launching.</p><h3>Step 5 — Make it permanent</h3><p>Add to ~/.zshrc:</p><pre>export CLAUDE_CODE_USE_BEDROCK=1<br>export AWS_REGION=us-east-1<br>export AWS_PROFILE=my-dev-profile</pre><pre>source ~/.zshrc</pre><p>One thing to keep in mind: SSO sessions expire (usually every 8 hours). You won’t get a helpful error — Claude Code will just start failing. When that happens, re-run:</p><pre>aws sso login --profile my-dev-profile</pre><p>That’s the fix for most mysterious Bedrock errors after things were working fine.</p><h3>Part 2 — Claude Code with the Anthropic API</h3><p>Much simpler. Make sure the Bedrock variable is unset first:</p><pre>unset CLAUDE_CODE_USE_BEDROCK<br>claude</pre><p>At the login prompt, select <strong>Anthropic API</strong>, then either log in with your claude.ai account (Pro or Max required) or paste an API key from <a href="https://console.anthropic.com/">console.anthropic.com</a> → <strong>API Keys</strong> → <strong>Create Key</strong>.</p><p>Run /status to confirm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y0tScB-U016iDCf6X7BMFA.png" /></figure><h3>Part 3 — Switching between the two</h3><p>This is where the .env approach really breaks down if you have multiple projects. Environment variables set in one terminal session don&#39;t affect others, and it&#39;s easy to lose track of which mode you&#39;re in.</p><p>The simplest fix is shell aliases. Add these to ~/.zshrc:</p><pre># Claude via Amazon Bedrock<br>alias claude-bedrock=&#39;export CLAUDE_CODE_USE_BEDROCK=1 &amp;&amp; export AWS_REGION=us-east-1 &amp;&amp; claude&#39;<br><br># Claude via Anthropic API<br>alias claude-anthropic=&#39;unset CLAUDE_CODE_USE_BEDROCK &amp;&amp; claude&#39;</pre><pre>source ~/.zshrc</pre><p>Now you just run claude-bedrock or claude-anthropic. Always check /status after launching if you&#39;re not sure — the provider line makes it unambiguous.</p><h3>Cheat sheet</h3><pre># Bedrock<br>aws sso login --profile my-dev-profile   # re-auth when session expires<br>aws sts get-caller-identity              # verify credentials are live<br>claude-bedrock                           # launch<br><br><br># Anthropic API<br>claude-anthropic                         # launch<br># Inside Claude Code<br>/status                                  # check which provider is active<br># Check available Bedrock models in your account<br>aws bedrock list-inference-profiles --region us-east-1 | grep sonnet</pre><h3>Errors I actually hit</h3><p><strong>403 after initial setup</strong> — didn’t complete the Anthropic FTU form. Fix: go to Bedrock console, find the model, submit the form.</p><p><strong>Credentials expired mid-session</strong> — SSO tokens have a TTL. Fix: aws sso login --profile my-dev-profile and relaunch Claude.</p><p><strong>Claude Code ignoring my Bedrock config</strong> — the env variable was set in a different terminal tab. Fix: echo $CLAUDE_CODE_USE_BEDROCK to check, then export again in the current session or use the alias.</p><p><strong>Wrong AWS account getting billed</strong> — happened when I had multiple profiles and the wrong one was active. Fix: always verify with aws sts get-caller-identity before a long Claude Code session.</p><p>If you have AWS credits sitting unused and already use Claude Code via the Anthropic API, Bedrock is worth the one-time setup effort. The SSO configuration is the biggest hurdle — once that’s done, the rest is just environment variables.</p><p><em>References:</em></p><ul><li><a href="https://medium.com/@swagattripathy/stop-hardcoding-aws-access-keys-youre-one-git-push-away-from-a-disaster-b8155af9c218"><em>Stop Hardcoding AWS Access Keys — Swagat Tripathy</em></a></li><li><a href="https://code.claude.com/docs/en/amazon-bedrock"><em>Claude Code on Amazon Bedrock — Official Docs</em></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2f6498a2723" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>