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

完全なリソーススキーマ、引数、インポート構文は [Terraform Registry のドキュメント](https://registry.terraform.io/providers/AikidoTerraform/aikido/latest/docs).

## 管理できる内容

この provider は現在、次をサポートしています:

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

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

## 要件

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

## provider を設定する

{% 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 %}

### provider を宣言する

Terraform 設定に provider を追加してから、 `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`

これらが設定されている場合は、空の provider ブロックを使用できます:

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

{% endstep %}

{% step %}

### Aikido のリージョンを指定する（任意）

デフォルトでは、この provider は 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>

## 関連ドキュメント

* [Aikido 管理 API](https://apidocs.aikido.dev/)
* [AutoFix](/docs/docs-ja/autofixto/overview-aikido-autofix.md)
* [PR gating](/docs/docs-ja/prtorirsunogtingu/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 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/sonono/aikido-terraform-provider.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.
