> 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/autofix-to/connect-private-packages/aws-codeartifact-private-packages.md).

# AWS CodeArtifact - プライベートパッケージ

Aikido の AutoFix が、AWS CodeArtifact でプライベートパッケージをホストしているレジストリに接続できるようにします。

## Aikido での設定

Aikido は、AWS アカウント内に新しいロールを作成する CloudFormation テンプレートを提供します。このロールの権限は読み取り専用の CodeArtifact アクセスに限定されています。これは、Aikido の AWS アカウントに、あなたのアカウント内で新しく作成されたロールとの信頼関係を付与することで実現されます。

ロール作成後、Aikido が開始するために必要なのは特定の ARN だけで、アクセスキーもシークレットも不要です。

で [Aikido UI](https://app.aikido.dev/issues/fix/settings)、AutoFix > Settings > Connect Registry に移動し、

<figure><img src="/files/4e00e9a22cd1223419c921d2a6e453ec19982b91" alt=""><figcaption></figcaption></figure>

モーダル内の手順に従ってください:

* IAM ロールとポリシーを作成
* CloudFormation の出力からロール ARN を貼り付ける
* AWS コンソールに表示されている CodeArtifact リポジトリのドメインを入力します（例: mydomain）
* CodeArtifact ドメインがホストされている AWS リージョンを選択します（例: us-east-1）

<figure><img src="/files/bf9ba3bc9fae6016c775c321c386b6b83bcae6eb" alt=""><figcaption></figcaption></figure>

Aikido AutoFix は `CODEARTIFACT_AUTH_TOKEN` 環境変数をプロセス中に設定します。この環境変数は、その後パッケージマネージャーが CodeArtifact レジストリに認証するために使用できます。必要なレジストリ固有の設定については以下を参照してください。

## NPM と PNPM <a href="#npm--pnpm" id="npm--pnpm"></a>

基本的な `.npmrc` 設定が、プライベートパッケージがインストールされるリポジトリ（または Aikido の設定）に存在している必要があります。以下の情報を含め、プレースホルダーはあなたの情報に置き換えてください:

```
@pied-piper:registry=https://mydomain-123456789.d.codeartifact.us-east-1.amazonaws.com/npm/pied-piper
//mydomain-123456789.d.codeartifact.us-east-1.amazonaws.com/npm/pied-piper/:_authToken=${CODEARTIFACT_AUTH_TOKEN}
```

AutoFix 実行中に、 `${CODEARTIFACT_AUTH_TOKEN}` は実際の認証トークンに置き換えられます。

## Poetry

Poetry に CodeArtifact Auth Token を使用させるには、追加の環境変数を設定する必要があります:  `POETRY_HTTP_BASIC_[SOURCE]_USERNAME` を `aws`  を設定してください。必ず `[SOURCE]` を、あなたの `pyproject.toml` 内にあるソース名（大文字）に置き換えてください。例:

```toml
[[tool.poetry.source]]
name = "artifact"
url = "https://repo-1234567890.d.codeartifact.eu-west-1.amazonaws.com/pypi/poetry/simple/"
```

この例におけるソース名は `artifact`です。したがって、 `POETRY_HTTP_BASIC_ARTIFACT_USERNAME` 環境変数を `aws`.

のように設定すると、 `POETRY_HTTP_BASIC_[SOURCE]_USERNAME` を `aws` 、AutoFix が自動的に `POETRY_HTTP_BASIC_[SOURCE]_PASSWORD` を入力し、Poetry が AWS CodeArtifact リポジトリにアクセスできるようになります。

## UV

UV に CodeArtifact Auth Token を使用させるには、追加の環境変数を設定する必要があります:  `UV_INDEX_[INDEX]_USERNAME` を `aws`  を設定してください。必ず `[INDEX]` を、あなたの `pyproject.toml` 内にあるソース名（大文字）に置き換えてください。例:

```toml
[[tool.uv.index]]
name = "artifact"
url = "https://repo-1234567890.d.codeartifact.eu-west-1.amazonaws.com/pypi/uv-example/simple/"
```

この例におけるインデックス名は `artifact`です。したがって、 `UV_INDEX_ARTIFACT_USERNAME` 環境変数を `aws`.

のように設定すると、 `UV_INDEX_[INDEX]_USERNAME` を `aws` 、AutoFix が自動的に `UV_INDEX_[INDEX]_PASSWORD` であり、これにより UV は AWS CodeArtifact リポジトリにアクセスできるようになります。

## Maven

AWS CodeArtifact 接続の設定後、 `CODEARTIFACT_AUTH_TOKEN` 環境変数を `settings.xml` で使用できます。settings.xml ファイルは Maven のプライベートレジストリ設定で次のように設定できます。例:

{% code title="settings.xml" %}

```
<servers>
    <server>
        <id>codeartifact</id>
        <username>aws</username>
        <password>${env.CODEARTIFACT_AUTH_TOKEN}</password>
    </server>
</servers>
```

{% endcode %}

## 設定の確認方法

依存関係の AutoFix を作成すると、進行状況のモーダルに次のメッセージが表示されるはずです:

* 3 つ以上の環境変数を設定
* AWS CodeArtifact 認証トークンが正常に設定されました

<figure><img src="/files/14c1f2e4db3d451096f5cc65e798e7e62b0f2973" alt=""><figcaption></figcaption></figure>

AWS の認証情報が正しくない、または権限が不足している場合は、'Failed to authenticate to AWS CodeArtifact' という警告メッセージが表示されます:

<figure><img src="/files/7b2ece04fe7f98bc72f269c8f17b392f496fa612" alt=""><figcaption></figcaption></figure>

AWS CodeArtifact に関するメッセージがない場合、設定が完了していないことを意味します。

## AWS アクセスキーを使用する（非推奨）

AWS CodeArtifact への接続を有効にするには、次の 4 つの環境変数を指定する必要があります:

* `AWS_CODE_ARTIFACT_ACCESS_KEY`: `AWSCodeArtifactReadOnlyAccess` 権限が必要であり、アセスメントに対する保留中のクレジットも精算されている必要があります。開始から 6 か月以内のアセスメントの発見事項を再テストできます。
* `AWS_CODE_ARTIFACT_SECRET_KEY`: `AWSCodeArtifactReadOnlyAccess` 権限が必要であり、アセスメントに対する保留中のクレジットも精算されている必要があります。開始から 6 か月以内のアセスメントの発見事項を再テストできます。
* `AWS_CODE_ARTIFACT_DOMAIN`: AWS コンソールに表示されている CodeArtifact リポジトリのドメイン（例: mydomain）
* `AWS_CODE_ARTIFACT_REGION`: CodeArtifact ドメインがホストされている AWS リージョン（例: us-east-1）

これら 4 つの環境変数が設定されると、Aikido AutoFix は `CODEARTIFACT_AUTH_TOKEN` 環境変数をプロセス中に設定します。この環境変数は、その後パッケージマネージャーが CodeArtifact レジストリに認証するために使用できます。必要なレジストリ固有の設定については以下を参照してください。

これらの環境変数は Autofix > Settings > Connect Registry > [環境変数を設定](/docs/docs-ja/autofix-to/connect-private-packages/custom-config-private-packages.md).


---

# 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/autofix-to/connect-private-packages/aws-codeartifact-private-packages.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.
