0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

claude code action に bedrock を用いる

Last updated at Posted at 2025-05-28

以下の記事を参考に claude code action (cca) を bedrock で設定します
ここでは設定部だけに特化して記述します
細かな補足は元の記事をご参照ください

bedorck で claude 4 を有効化

model 申請画面から claude 4 を有効化します
cross region で用いる事になるので、オレゴン、オハイオ、バージニアで有効化すると良いかもしれません

以下はオレゴンの model list URL になります

AWS

AWS に github をプロバイダとして登録しロールを作成する

OIDC の設定

  • aws iam を開く
  • IDプロバイダ を選択
  • プロバイダ を追加を選択
    スクリーンショット 2025-05-28 21.31.30.png
  • 設定
    • プロバイダのタイプ
      • OpenID Connect を選択
    • プロバイダの URL
      • https://token.actions.githubusercontent.com
    • 対象者
      • sts.amazonaws.com
        スクリーンショット 2025-05-28 21.32.03.png
  • プロバイダを追加 を選択し完了

ロールを作成

  • IAM を開く
  • 左メニューから ロール を選択
  • ロールを作成 を選択
    スクリーンショット 2025-05-28 21.38.20.png
  • カスタム信頼ポリシー を選択
    スクリーンショット 2025-05-28 21.44.28.png
  • カスタムポリシーへ、以下の sample を元に入力する
    • <AWS_ACCOUNT_ID> 部を aws account id の数値へ置換
    • <REPSITORY_NAME> へ許可する github repository へ置換
    • 補足、以下の記述では特定のアカウントの全リポジトリからのアクセスを受け付ける設定となります
    • 入力後、次へ を選択
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "RoleForGitHubActions",
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::<AWS_ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
                },
                "StringLike": {
                    "token.actions.githubusercontent.com:sub": "repo:<ACCOUNT_NAME>/*:*"
                }
            }
        }
    ]
}
  • ロールに付与する権限を選択
    • AmazonBedrockFullAccess を選択
    • 次へ を選択
      スクリーンショット 2025-05-28 21.38.52.png
  • 名前を付与
    • ロール名を入力
    • ロールを作成 を選択し完了します
      スクリーンショット 2025-05-28 21.39.00.png
  • 作成されたロールの ARN を控える
    スクリーンショット 2025-05-28 21.51.56.png

github

claude app を install

  • 以下 URL より claude app を install
    • install 対象の github account を選択し
    • 権限を付与するリポジトリを選択する

ARN をリポジトリへ設定

  • 設定対象の github リポジトリを開く
  • Settings を開く
  • Secrets and variables から Actions を選択
  • Repository secrets へ
    • Name : AWS_ROLE_TO_ASSUME
    • value : ロールで作成した ARN を入力

スクリーンショット 2025-05-28 21.55.11.png

github workflow を作成

以下記事の設定内容を引用させていただきます

  • .github/workflows/claude.yml を作成
  • 以下を記述し push する
Claude Code
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request_review:
    types: [submitted]

jobs:
  claude:
    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 == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
    runs-on: ubuntu-latest
    env:
      ANTHROPIC_BEDROCK_BASE_URL: "https://bedrock-runtime.us-west-2.amazonaws.com"
    permissions:
      contents: read
      pull-requests: read
      issues: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Configure AWS Credentials (OIDC)
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
          aws-region: us-west-2

      - uses: anthropics/claude-code-action@beta
        with:
          model: "us.anthropic.claude-sonnet-4-20250514-v1:0"
          use_bedrock: "true"

以上で完了となります

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?