[BUG] Claude Code support for AWS credentials with MFA support
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Details -
- current claude code version
````
$ claude --version
2.0.73 (Claude Code)
- current aws cli version
````
$ aws --version
aws-cli/2.28.10 Python/3.13.6 Darwin/24.1.0 source/x86_64
- here are my aws environment settings,
- users have iam accounts with access-key, secret-key and mfa enabled.
- temporary credentials are created using the mfa token and the following properties are set,
```
# ensure no previous settings exists
unset AWS_ACCESS_KEY_ID; unset AWS_SECRET_ACCESS_KEY; unset AWS_SESSION_TOKEN
# set aws-account profile using existing aws credentials
export AWS_PROFILE=aws-account-profile-1
# generate temporary credentials with mfa
aws sts assume-role --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/${ROLE_NAME} --role-session-name ${SESSION_NAME} --serial-number arn:aws:iam::${AWS_ACCOUNT_ID}:mfa/mfa-device --duration-seconds 43200 --token-code xxxxx > /tmp/aws-token.json
# sample file - /tmp/aws-token.json
{
"Credentials": {
"AccessKeyId": "xxxxx",
"SecretAccessKey": "xxxxx",
"SessionToken": "xxxx",
"Expiration": "2025-12-19T05:57:00+00:00"
},
}
# set the temporary values from the tokens generated
export AWS_ACCESS_KEY_ID=$(cat /tmp/aws-token.json | jq -r .Credentials.AccessKeyId); export AWS_SECRET_ACCESS_KEY=$(cat /tmp/aws-token.json | jq -r .Credentials.SecretAccessKey); export AWS_SESSION_TOKEN=$(cat /tmp/aws-token.json | jq -r .Credentials.SessionToken);
# confirmed the aws cli is working using the temporary tokens
$ aws sts get-caller-identity
{
"UserId": "xxxx:xxxx",
"Account": "xxxx",
"Arn": "arn:aws:sts::xxxxx:assumed-role/xxxx/xxxxx"
}
```
- while starting up claude code and trying to use the anthropic modes from aws bedrock, I get the following error -
````
API Error: Profile ${AWS_ACCOUNT_NAME} requires multi-factor authentication, but no MFA code callback was provided.
- so far whatever I have researched, it seems claude code does honor these environment properties, so I am not sure why above issue will happen.
````
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
What Should Happen?
The expectation is that like any other application, claude code will be able to honor the aws credentials with mfa authentication process.
Error Messages/Logs
Steps to Reproduce
The steps listed in the bug description, describes on how to reproduce the issue.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.73
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗