Closed8
Claude Code ActionをBedrockで利用する

GitHub OIDC Identity Providerの設定と、IAMロールの作成
github-actions-bedrock-oidc-role.yml
Parameters:
GitHubOrg:
Type: String
Default: <your organization name>
Resources:
Role:
Type: AWS::IAM::Role
Properties:
RoleName: GitHubActionsBedrockOIDCAdminRole
ManagedPolicyArns: [arn:aws:iam::aws:policy/AmazonBedrockFullAccess]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRoleWithWebIdentity
Principal:
Federated: !Ref GithubOidc
Condition:
StringLike:
token.actions.githubusercontent.com:sub: !Sub repo:${GitHubOrg}/*:*
GithubOidc:
Type: AWS::IAM::OIDCProvider
Properties:
Url: https://token.actions.githubusercontent.com
ThumbprintList: [6938fd4d98bab03faadb97b34396831e3780aea1,1c58a3a8518e8759bf075b76b750d4f2df264fcd]
ClientIdList:
- sts.amazonaws.com
Outputs:
Role:
Value: !GetAtt Role.Arn

Claude GitHub Appをインストール

作成したロールをGitHubSecretsに登録
公式だと AWS_ROLE_TO_ASSUME
だけど、実運用では他のSecretsもあり分かりにくいので AWS_BEDROCK_ROLE_TO_ASSUME
で登録

GitHubActionsワークフロー
name: Claude Code Action
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
jobs:
claude-pr:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
runs-on: ubuntu-latest
env:
AWS_REGION: ap-northeast-1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS Credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_BEDROCK_ROLE_TO_ASSUME }}
aws-region: ap-northeast-1
- uses: anthropics/claude-code-action@beta
with:
trigger_phrase: "@claude"
timeout_minutes: "60"
github_token: ${{ steps.app-token.outputs.token }}
use_bedrock: "true"
model: "apac.anthropic.claude-3-7-sonnet-20250219-v1:0"

実行中のエラー
{
"type": "result",
"subtype": "success",
"cost_usd": 0,
"is_error": true,
"duration_ms": 1275,
"duration_api_ms": 0,
"num_turns": 1,
"result": "API Error (anthropic.claude-3-7-sonnet-20250219-v1:0): 400 Invocation of model ID anthropic.claude-3-7-sonnet-20250219-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.",
"total_cost": 0,
"session_id": "4241f69e-111c-4366-9d19-b8addffd512a"
}
これはAmazon Bedrock上でAnthropic Claude 3.7 Sonnetモデルを「on-demand throughput(従量課金)」で直接呼び出そうとした際に発生する、よくあるエラーです
Claude 3.7 Sonnetなど一部の新しいモデルは、従来のmodel ID(例: anthropic.claude-3-7-sonnet-20250219-v1:0)を直接指定してのオンデマンド呼び出しがサポートされていません。
このモデルは**「推論プロファイル(Inference Profile)」**経由でのみ利用可能です。
推論プロファイルのモデルIDを確認するコマンド
aws bedrock list-inference-profiles --query "inferenceProfileSummaries[].inferenceProfileId" --output table
----------------------------------------------------
| ListInferenceProfiles |
+--------------------------------------------------+
| apac.anthropic.claude-3-sonnet-20240229-v1:0 |
| apac.anthropic.claude-3-5-sonnet-20240620-v1:0 |
| apac.anthropic.claude-3-haiku-20240307-v1:0 |
| apac.anthropic.claude-3-5-sonnet-20241022-v2:0 |
| apac.amazon.nova-micro-v1:0 |
| apac.amazon.nova-lite-v1:0 |
| apac.amazon.nova-pro-v1:0 |
| apac.anthropic.claude-3-7-sonnet-20250219-v1:0 |
| apac.anthropic.claude-sonnet-4-20250514-v1:0 |
+--------------------------------------------------+

Cluade Codeがコミットできない問題
GitHubActionsのログでは以下のメッセージ
2025-06-01T03:38:56.3794724Z content: "Error: Failed to create tree: 403 - {\"message\":\"Resource not accessible by integration\",\"documentation_url\":\"https://docs.github.com/rest/git/trees#create-a-tree\",\"status\":\"403\"}"
mcp__github_file_ops__commit_files ツールが呼び出された際にこの403エラーが発生
このツールはファイルのコミットを担当
issueが立っている
このスクラップは3ヶ月前にクローズされました