[FEATURE] Add BEDROCK_AWS_PROFILE env variable or config flag to make Bedrock independent from current profile
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When using Bedrock as the model in Claude Code with the AWS_PROFILE environment variable instead of a Bedrock token, the AWS_PROFILE variable overwrites the currently user-set profile. This becomes an issue when I want to use Claude Code to interact with AWS resources in a different account than the one used for my Bedrock model, while going through the AWS-provided MCP instead of making direct awscli calls from Claude Code (as a good practice to prevent the agent from performing unintended actions on the AWS side, this MCP does not support adding the profile flag in calls and Claude Code uses the currently set profile in the environment variable).
Currently, Claude Code uses the same environment variable to specify profile for both Bedrock and all AWS interactions within its environment. Using different AWS accounts for Bedrock and other AWS calls is already possible by using Bedrock access tokens and not setting the AWS_PROFILE variable, since all AWS calls—whether via MCP or AWS CLI—will then use the default profile.
However, not being able to specify a separate profile exclusively for Bedrock makes the configuration far less convenient and prevents the use of auto-refresh sso for this purpose. It also introduces a gap in Claude Code functionality between using Bedrock and other models, as with non-AWS models there is no issue with swapping between doing calls to different AWS accounts
Proposed Solution
Add either BEDROCK_AWS_PROFILE env variable input or bedrockAwsProfile configuration option to specify, that Claude Code will use this specific user profile for the Bedrock it uses, allowing the user to use their default profile for other interactions via AWS-provided MCP or direct AWSCli calls, thus giving users full control over what credentials are used for AWS calls
Alternative Solutions
_No response_
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
- I'm working on a cloud based app and use Bedrock as a model for my local Claude Code
- Bedrock model I use is on a different account than the one I want to deploy the app on
- I need to do modifications to my terraform infrastructure and want Claude Code to read some information from AWS to do those changes
- I cannot do that without using a Bedrock Access Token, as when Claude Code is configured to use a specific AWS_PROFILE for Bedrock it cannot call AWS for information using other profiles (the env variable used for that is the same as the one used to set up Bedrock)
Additional Context
_No response_
Showing cached comments. Read the full discussion on GitHub ↗
9 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
First two issues were closed with no resolution and no answers, the last one is simply asking on how to configure the profile
Two-part fix needed for Bedrock credential isolation
This issue has been reported repeatedly since February 2025 and auto-closed every time without resolution. Here is the full chain:
| Issue | Title | Closed By |
|-------|-------|-----------|
| #148 | Feature request: allow to set AWS profile | Stale bot |
| #11953 | awsCredentialExport seems to have lower priority than .aws/credentials | Stale bot (despite active comments) |
| #20384 | Separate AWS profiles for Bedrock model calls and AWS API calls | Duplicate bot → #148 |
| #25394 | Separate AWS profile for Bedrock API calls vs. shell command environment | Stale bot |
| #29765 | Bedrock Credentials inherited by child processes, override ~/.aws/ | Duplicate bot → #25394 |
Each "duplicate" target was itself already closed. No human from Anthropic has addressed the underlying problem.
The fix has two distinct parts:
Part 1:
awsCredentialExportshould override the default AWS credential chainCurrently, if
~/.aws/credentialsorAWS_PROFILEprovides valid credentials,awsCredentialExportis silently skipped (#11953). The debug log confirms this:This is backwards.
awsCredentialExportis a Claude-specific setting that users explicitly configure — it should take priority over ambient AWS credentials, not be overridden by them. The whole point of configuringawsCredentialExportis to provide different credentials for Bedrock than what's already in the environment.Part 2: Introduce
CLAUDE_BEDROCK_AWS_PROFILE(orBEDROCK_AWS_PROFILE)A dedicated env var / config option that Claude Code uses exclusively for Bedrock API calls. Shell commands and child processes should inherit the user's ambient
AWS_PROFILE(or no profile), not the Bedrock one.Proposed credential resolution order for Bedrock calls:
awsCredentialExport(explicit credential command — highest priority)CLAUDE_BEDROCK_AWS_PROFILE(dedicated Bedrock profile)AWS_PROFILE,~/.aws/credentials, instance metadata, etc.)For child processes (shell commands, MCP servers):
This is a productivity blocker for anyone using separate AWS accounts for Bedrock vs. development work. The current behaviour means shell commands and MCP servers silently authenticate as the wrong AWS identity, leading to confusing permission errors or operations against unintended accounts.
This. I've found the 'awsCredentialExport' option some time after opening this issue and was positively excited that I might be able to go around it. Well, I wasn't able to, as even after writing a custom credentials provider the only thing I managed to create was a fallback mechanism for when the currently active profile is somehow broken (that's the way I tested it at first, I broke the session token for the active profile and checked if I still can interact with Bedrock via Claude Code). It turned out that my provider was silently ignored when the active profile was working and the only reason I found out was that I introduced my own logging to my custom provider and found no logs for a situation when it should have logged stuff.
This behaviour is not intuitive and doesn't really make sense, as when I use a custom credentials provider it's my conscious decision to do so and it should take precedence over the active profile instead of just being a fallback. Not even mentioning the fact that the bedrock profile choice should just be a configuration option, it's even available in other tools that directly compete with Claude Code.
This would make Claude Code much more useful for my team. AWS access is required to fetch the container with build tools, so it's a constant hassle. Many of us have been switching to Cursor because we don't have this problem with it.
The behavior here seems to contradict the docs:
Putting environment variables like
AWS_PROFILEin your settings file does, in fact, leak them to other processes (namely, every process that Claude Code spins up).If anyone is looking for a workaround, you can use the CLAUDE_ENV_FILE (not sure if this works with MCP):
Make a .env file somewhere such as the ~/.claude directory with this line:
export AWS_PROFILE=<your personal profile>Then in the claude settings.json set these environment variables:
Note that the CLAUDE_ENV_FILE doesn't support tilde expansion here.
But there definitely needs to be an option to simply set the Bedrock profile directly.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
I noticed this in the Claude Code 2.1.172 changelog entry:
I confirmed that I no longer need to set the
AWS_REGIONenv var for Claude: I just haveAWS_PROFILEset, and it uses the region defined for that profile in~/.aws/config.So that partly solves the problem here, at least. Having
AWS_REGIONset to my Bedrock region was the main source of my agent's AWS commands getting tripped up.