はじめに
Bedrock経由でclaude codeを使ってみた時の設定のメモです
bedrockを使える状態にする
aws コンソールで、Bedrockを開く。
Model catalogでSonnet 4.5をみつけて、Playgroundで開き、チャットして動作させる。
最初に利用する時、利用者の情報をいくつか質問されます。質問された場合は答えます。
これでモデルにアクセスできる状態となります。
aws cliでlog inする。
検証した環境では、ssoログインを使っているので、ssoでログインします。
profileはdefault以外を使いた場合は、適宜変更してください。
$ aws configure sso --profile default
SSO session name (Recommended): xxxxxxxxxx
SSO start URL [None]: https://d-xxxxxxxxx.awsapps.com/start/#
SSO region [None]: ap-northeast-1
SSO registration scopes [sso:account:access]:
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:
https://oidc.ap-northeast-1.amazonaws.com/~~省略~~
There are 14 AWS accounts available to you.
Using the account ID xxxxxxxxxxxxxxxx
The only role available to you is: AdministratorAccess
Using the role name "AdministratorAccess"
CLI default client Region [None]: ap-northeast-1
CLI default output format [None]: json
To use this profile, specify the profile name using --profile, as shown:
aws s3 ls --profile default
Inference Profile IDを取得
aws bedrock list-inference-profiles --region ap-northeast-1 --query 'inferenceProfileSummaries[?contains(inferenceProfileName, `Sonnet 4.5`)].[inferenceProfileName, inferenceProfileId]' --output table
----------------------------------------------------------------------------------------
| ListInferenceProfiles |
+---------------------------------+----------------------------------------------------+
| JP Anthropic Claude Sonnet 4.5 | jp.anthropic.claude-sonnet-4-5-20250929-v1:0 |
| Global Claude Sonnet 4.5 | global.anthropic.claude-sonnet-4-5-20250929-v1:0 |
+---------------------------------+----------------------------------------------------+
日本から使用するので、jp.anthropic.claude-sonnet-4-5-20250929-v1:0の方をつかってみます。
環境変数を設定してclaudeを起動
export AWS_PROFILE=default
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=ap-northeast-1
export ANTHROPIC_MODEL='jp.anthropic.claude-sonnet-4-5-20250929-v1:0'
claudeを起動してみます
bedlockのSonnet 4.5を使用できました
/modelコマンドで指定したモデルが使われていることを確認できました
課題
作業用のAWSアカウントとBedrockのアカウントを別にしたいと思ったんですが、この方法は見つかってません。

