> 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 チェックも同じワークフローに合わせたい場合に便利です。

完全なリソーススキーマ、引数、import 構文は次に記載されています: [Terraform Registry ドキュメント](https://registry.terraform.io/providers/AikidoTerraform/aikido/latest/docs).

## 管理できる内容

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

* **リポジトリ**: 既存のコードリポジトリを有効化または無効化し、感度、接続状態、ラベルを設定
* **AutoFix 設定**: 依存関係、SAST、Aikido Pentest の検出結果に対するワークスペース AutoFix を設定
* **PRチェック**: リポジトリごとのプルリクエストゲーティングを設定（重大度しきい値、スキャン種類、インラインコメント、Deep Review）

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

## 要件

* Terraform 1.0 以降
* 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>

## 関連ドキュメント

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