> 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>

**前提条件**: Local Scanning を許可するアカウントを作成済みであることを確認してください。 [Local Scanning アカウントの作成方法の詳細](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 ローカルスキャナーを使用してセキュリティスキャンを実行します。

## 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)
* 認証トークンを生成してコピーします。このトークンを表示できるのは一度だけであることに注意してください。
* このトークンを AWS Secrets Manager に AIKIDO\_API\_KEY というキーで追加し、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.
