> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kdosukyan/local-code-scanning/aws-codepipeline-setup-for-local-code-scanning.md).

# ローカルコードスキャンのためのAWS CodePipelineセットアップ

Aikido Security Local Scanner は、Aikido Security のスキャンをお使いの環境内で実行できるようにするツールです。これにより、コードが社外へ出ることはありません。スキャンはローカルで実行され、その結果は Aikido Security プラットフォームにアップロードされます。この構成により、レポート目的で Local Scanner を AWS CodePipeline に簡単に統合できます。

## ローカルスキャンの設定方法 <a href="#how-to-set-up-local-scanning" id="how-to-set-up-local-scanning"></a>

**前提条件**: ローカルスキャンを利用できるアカウントを作成しておいてください。 [ローカルスキャン用アカウントの作成に関する詳細](https://help.aikido.dev/en/articles/9070345-how-to-create-an-account-for-local-scanning-on-aikido).

このガイドでは、AWS CodePipeline と AWS CodeBuild を使用して AWS 上に CI パイプラインを作成します。このパイプラインは、コンテナイメージ内で Aikido Security local scanner を使ってセキュリティスキャンを実行します。

## 1. CodeBuild プロジェクトを作成する

まず、スキャンを実行する CodeBuild プロジェクトを作成します。

CodeBuild に移動する

1. AWS コンソールを開く
2. CodeBuild に移動する
3. \[ビルドプロジェクトの作成] をクリックする

#### 次の `aikido-security-scan` プロジェクトを作成します。

* ソース: 選択 `ソースなし`。ソースは CodePipeline によって提供されます。
* 環境:

  * イメージ: カスタムイメージ
  * コンピュート: EC2
  * 環境タイプ: Linux コンテナ
  * イメージレジストリ: 他のレジストリ
  * 外部レジストリ URL: public.ecr.aws/z1o3v2w5/aikidosecurity/local-scanner:latest

  <figure><img src="/files/6fa33c1c9e273b65d7bff6e0afa4023018e480da" alt=""><figcaption></figcaption></figure>
* Buildspec:

  ```
  version: 0.2

  phases:
    build:
      commands:
        - aikido-local-scanner scan . --apikey $AIKIDO_API_KEY --repositoryname MyRepo --branchname myDefaultBranch
  ```

#### CodeBuild プロジェクトへの API キーの追加

* 次へ移動 [Local Scanner 設定ページ](https://app.aikido.dev/settings/integrations/localscan)
* 認証トークンを生成してコピーします。このトークンは一度しか表示できないことに注意してください。
* このトークンを key AIKIDO\_API\_KEY として AWS Secrets Manager に追加し、aikido/local-scanner-api-key のような名前を付けます。完全なシークレット ARN を控えておいてください。すぐに必要になります。
* CodeBuild プロジェクトは IAM サービスロールで実行されます。このロールにはシークレットを読み取る権限が必要です。ARN をシークレットの ARN に置き換えて、次のポリシーを追加してください

```
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "secretsmanager:GetSecretValue"
      ],
      "Resource": "arn:aws:secretsmanager:<region>:<account-id>:secret:aikido/local-scanner-api-key-*"
    }
  ]
}
```

* 次に CodeBuild プロジェクトに戻り、\[Edit] > \[Environment] > \[Additional Configuration] をクリックします。環境変数を追加してください:
  * 名前: AIKIDO\_API\_KEY
  * 値: aikido/local-scanner-api-key
  * タイプ: Secrets Manager

値の形式は \<secret-name>:\<json-key> です。CodeBuild はビルド時にこれを自動的に解決し、その値を環境に注入します。詳細は [AWS ドキュメント](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_EnvironmentVariable.html) を参照してください。

## 2. CodePipeline を作成する

スキャンしたいリポジトリ用のパイプラインを設定します。\
デフォルトブランチへの変更でトリガーされるソースステージを追加します。Build ステージでは、ビルドプロバイダーとして AWS CodeBuild を選択し、 `aikido-security-scan` ビルドプロジェクトを追加します。これにより、パイプラインは先ほど作成したビルドジョブに接続されます。

## 3. スキャン結果を確認する

最初のスキャンが完了したら、Aikido Feed に移動して結果を確認できます。リポジトリが作成され、スキャンによるすべての結果が含まれています。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/kdosukyan/local-code-scanning/aws-codepipeline-setup-for-local-code-scanning.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
