> 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/sonono/aikido-terraform-provider.md).

# Aikido Terraform プロバイダー

公式の Aikido Terraform プロバイダーを使用して、Aikido リソースをコードとして管理します [管理 API](https://apidocs.aikido.dev/)。これは、すでに Terraform でインフラをプロビジョニングしており、リポジトリの有効化、AutoFix 設定、PR チェックも同じワークフローに従わせたい場合に便利です。

このプロバイダーは、以下の両方で公開されています。 [Terraform Registry](https://registry.terraform.io/providers/AikidoTerraform/aikido/latest/docs) と [OpenTofu Registry](https://search.opentofu.org/provider/aikidoterraform/aikido/latest)、そのため Terraform と OpenTofu で動作します。完全なリソーススキーマ、引数、インポート構文は Terraform Registry のドキュメントにあります。

## 管理できる内容

現在、プロバイダーは次をサポートしています:

* **リポジトリ**: 既存のコードリポジトリを有効化または無効化し、感度、接続状態、ラベルを設定します
* **AutoFix 設定**: 依存関係、SAST、Aikido Pentest の検出結果に対するワークスペースの AutoFix を構成します
* **PRチェック**: リポジトリごとのプルリクエストゲートを構成します（重大度しきい値、スキャン種別、インラインコメント、Deep Review）
* **チームと権限**: チームとユーザー権限を設定します
* **チームとリソースのマッピング**: リポジトリとコンテナをチームに割り当てます
* **タスクトラッカーへのリポジトリ/チームマッピング**

{% hint style="info" %}
このプロバイダーは、Aikido にすでに存在するリポジトリ（Git プロバイダーから同期されたもの）の設定を管理します。Git リポジトリを作成したり、新しい Git 統合を接続したりはしません。
{% endhint %}

## 要件

* Terraform 1.0 以降、または OpenTofu
* API アクセス権のある Aikido ワークスペース
* 次の場所から取得した OAuth2 クライアント認証情報: [Aikido REST API 統合ページ](https://app.aikido.dev/settings/integrations/api/aikido/rest)

## プロバイダーを設定する

{% stepper %}
{% step %}

### API 認証情報を作成する

1. へ移動 [Aikido REST API 統合ページ](https://app.aikido.dev/settings/integrations/api/aikido/rest).
2. クライアント ID とクライアントシークレットを作成します。
3. シークレットは安全に保管してください。ページを離れると、再度表示することはできません。

以下を参照してください [API 認可ドキュメント](https://apidocs.aikido.dev/reference/authorization) Aikido が API クライアントを認証する方法の詳細について。
{% endstep %}

{% step %}

### プロバイダーを宣言する

Terraform 設定にプロバイダーを追加してから、次を実行します `terraform init`:

{% code title="main.tf" %}

```terraform
terraform {
  required_providers {
    aikido = {
      source  = "AikidoTerraform/aikido"
      version = "~> 1.1"
    }
  }
}

provider "aikido" {
  client_id     = var.aikido_client_id
  client_secret = var.aikido_client_secret
}
```

{% endcode %}

資格情報は、ハードコードする代わりに環境変数で渡すこともできます:

* `AIKIDO_CLIENT_ID`
* `AIKIDO_CLIENT_SECRET`

それらを設定すると、空のプロバイダーブロックを使用できます:

```terraform
provider "aikido" {}
```

{% endstep %}

{% step %}

### 対象の Aikido リージョンを指定します（任意）

デフォルトでは、プロバイダーは EU API（`https://app.aikido.dev/api`）を使用します。ワークスペースが別のリージョンでホストされている場合は、次を設定します: `base_url` （または `AIKIDO_BASE_URL` 環境変数）を、ログインに使用するアプリの URL に合わせて設定します:

| Aikido ログイン URL     | 例 `base_url`                      |
| ------------------- | --------------------------------- |
| `app.aikido.dev`    | `https://app.aikido.dev/api` （既定） |
| `app.us.aikido.dev` | `https://app.us.aikido.dev/api`   |
| `app.au.aikido.dev` | `https://app.au.aikido.dev/api`   |
| `app.me.aikido.dev` | `https://app.me.aikido.dev/api`   |

```terraform
provider "aikido" {
  client_id     = var.aikido_client_id
  client_secret = var.aikido_client_secret
  base_url      = "https://app.us.aikido.dev/api"
}
```

{% endstep %}
{% endstepper %}

## 設定例

```terraform
resource "aikido_repository" "app" {
  id     = "12345"
  active = true

  sensitivity  = "sensitive"
  connectivity = "connected"

  labels = ["payments", "production"]
}

resource "aikido_autofix_dependency_settings" "workspace" {
  enabled                      = true
  severity_filter              = "critical_and_high_only"
  repos_scope                  = "all"
  use_aikido_library_for_major = true
}

resource "aikido_repo_pr_checks_settings" "app" {
  code_repo_id = 12345

  minimum_severity                  = "high"
  fail_on_dependency_scan            = true
  fail_on_sast_scan                  = true
  fail_on_iac_scan                   = true
  fail_on_secrets_scan               = true
  fail_on_malware_scan               = true
  post_inline_comments_min_severity  = "critical"

  minimum_license_severity = "high"

  fail_on_code_quality_scan                      = true
  enable_code_quality_scan                       = true
  post_code_quality_inline_comments_min_severity = "medium"
}
```

各引数、インポート ID、リソース固有の動作については、公式ドキュメントを参照してください:

<a href="https://registry.terraform.io/providers/AikidoTerraform/aikido/latest/docs" class="button primary" data-icon="book">Terraform Registry のドキュメント</a> <a href="https://search.opentofu.org/provider/aikidoterraform/aikido/latest" class="button secondary" data-icon="book">OpenTofu Registry</a>

## 関連ドキュメント

* [Aikido 管理 API](https://apidocs.aikido.dev/)
* [AutoFix](/docs/docs-ja/autofix-to/overview-aikido-autofix.md)
* [PRゲーティング](/docs/docs-ja/pr-torirsugtingu/aikido-ci-gating-functionality.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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/docs/docs-ja/sonono/aikido-terraform-provider.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
