> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS デプロイガイド

# Dify Enterprise Edition デプロイガイド (AWS)

Dify Enterprise Edition を円滑にデプロイするため、以下のインフラ要件および設定手順に従ってください。

***

## 注意事項

**‼️必ずバージョン 2.8.0 以上へアップグレードし、マイグレーションを完了させてください。**‼️

***

## 1. インフラ要件

### 必須 AWS サービス:

* **S3**
* **ECR**

### サポートされる認証方式:

Dify は、AWS サービスへのアクセスに以下の 2 つの方式をサポートします:

* **アクセスキー方式 (AK/SK):** 環境変数を通じて認証情報を提供
* **IRSA 方式:** IAM Roles for Service Accounts を用いたセキュアかつきめ細かいアクセス制御

***

## 2. アクセスキー方式

### Step 1: 認証情報の準備

**S3** と **ECR** の権限のみを持つ IAM ユーザーを作成し、Access Key と Secret Key を取得します。

### Step 2: Kubernetes Secret の作成

```bash theme={null}
kubectl create secret generic image-repo-secret --from-file=<path to .aws/credentials>
```

### **Step 3:** **values.yaml の更新**

```bash theme={null}
persistence:
  type: "s3"
  s3:
    endpoint: "https://s3.{region_code}.amazonaws.com"
    region: "{region_code}"
    bucketName: "your_bucket_name"
    useAwsS3: true
    useAwsManagedIam: false
    accessKey: "{your access key}"
    secretKey: "{your secret key}"

plugin_daemon:
  enabled: true
  replicas: 1
  apiKey: "dify123456"

plugin_connector:
  apiKey: "dify123456"
  imageRepoSecret: "image-repo-secret"
  imageRepoPrefix: "{account_id}.dkr.ecr.{region}.amazonaws.com/dify-ee"
  imageRepoType: ecr
  ecrRegion: "us-west-2"
```

### **Step 4: Plugin Daemon のデータベース設定**

```bash theme={null}
externalPostgres:
  enabled: true
  address: "rds_address"
  port: "5432"
  credentials:
    plugin_daemon:
      database: "dify_plugin_daemon"
      username: "{user}"
      password: "{password}"
      sslmode: "disable"
    audit:
      database: "audit"
      username: "{user}"
      password: "{password}"
      sslmode: "disable"
```

### **Step 5:**

### **リリースノートに従ってアップグレード（インストール）**

[https://langgenius.github.io/dify-helm/#/pages/3\_0\_0](https://langgenius.github.io/dify-helm/#/pages/3_0_0)

***

## **3. IRSA モード**

Access Key は企業環境で厳格に管理されるため、AWS Pod Identity (IRSA) の利用を推奨します。

### **✅ 利点**

* AWS のセキュリティベストプラクティスに準拠
* プラグイン実行環境のきめ細かな制御が可能

### **セットアップ**

#### **Step 1: IAM ロールと Service Account の準備**

* ##### **前提条件**

  * 利用可能な AWS リージョンおよび EKS クラスターが存在すること
  * Dify のファイル保存用の既存の S3 バケットがあること
  * kubectl がローカルにインストール・設定され、対象 EKS クラスターへアクセスできること
  * AWS CLI がインストールされ、ローカルに認証情報が設定されていること

##### **🚀オプション A: ワンクリックスクリプトの実行**

​	**‼️ ワンクリックスクリプトはデモおよびテスト用です。実運用に合わせて独自のスクリプトを開発してください。このデモスクリプトは Dify FDE チームから入手可能です。**

```
./irsa_one_click.sh
```

##### **🔨オプション B: 手動設定**

1. **EKS クラスターで IAM OIDC プロバイダを有効化**

   EKS クラスターと OIDC ID プロバイダを関連付けるために、[AWS公式ドキュメント](https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html) の手順に従ってください。この手順を完了しないと、IRSA を利用できません。

2. **IAM ポリシーの作成**

| **項目**          | **例の命名**                                           | **説明**                                 |
| --------------- | -------------------------------------------------- | -------------------------------------- |
| S3 Policy Name  | `dify-ee-irsa-<cluster_name>-s3-policy`            | 指定した S3 バケットへの完全アクセス                   |
| ECR Policy Name | `dify-ee-irsa-<cluster_name>-ecr-policy`           | ECR への完全アクセスおよび CloudTrail の読み取り専用アクセス |
| ECR Policy Name | `dify-ee-irsa-<cluster_name>-ecr-pull-only-policy` | ECR からの pull のみ許可                      |

1. **ポリシー付き IAM ロールの作成**

| **項目**                   | **例の命名**                                    | **policy**                                                                       |
| ------------------------ | ------------------------------------------- | -------------------------------------------------------------------------------- |
| IAM Role - S3            | `DifyEE-Role-<cluster_name>-s3`             | `dify-ee-irsa-<cluster_name>-s3-policy`                                          |
| IAM Role - S3 + ECR      | `DifyEE-Role-<cluster_name>-s3-ecr`         | `dify-ee-irsa-<cluster_name>-s3-policy` `dify-ee-irsa-<cluster_name>-ecr-policy` |
| IAM Role - ECR Pull-only | `DifyEE-Role-<cluster_name>-ecr-image-pull` | `dify-ee-irsa-<cluster_name>-ecr-pull-only-policy`                               |

1. **IAM ロールを ServiceAccount に関連付け**

| **用途**                  | **デフォルト名**            | **バインドする IAM ロール**                          | **説明**                             |
| ----------------------- | --------------------- | ------------------------------------------- | ---------------------------------- |
| dify-api, dify-worker 用 | dify-api-sa           | `DifyEE-Role-<cluster_name>-s3`             | バックエンドサービスが S3 にアクセス（ファイルアップロードなど） |
| dify-plugin-crd のビルド用   | dify-plugin-crd-sa    | `DifyEE-Role-<cluster_name>-s3-ecr`         | S3 へのアクセスやプラグインイメージレポジトリの操作を行う     |
| dify-plugin 実行時用        | dify-plugin-runner-sa | `DifyEE-Role-<cluster_name>-ecr-image-pull` | プラグイン実行時のイメージ pull に利用             |

#### **Step 2: 環境変数の設定**

リリースノートに従って、S3\_REGION、S3\_BUCKET\_NAME などの環境変数を設定します。

#### **Step 3:** **values.yamlの更新**

```bash theme={null}
persistence:
  type: "s3"
  s3:
    endpoint: "https://s3.{region_code}.amazonaws.com"
    region: "{region_code}"
    bucketName: "your_bucket_name"
    useAwsS3: true
    useAwsManagedIam: true

api:
  enabled: true
  replicas: 1
  innerApi:
    enabled: true
    apiKey: "dify123456"
  serverWorkerAmount: 1
  serviceAccountName: "dify-api-sa"

worker:
  enabled: true
  replicas: 1
  serviceAccountName: "dify-api-sa"

plugin_daemon:
  enabled: true
  replicas: 1
  apiKey: "dify123456"

plugin_connector:
  apiKey: "dify123456"
  customServiceAccount: "dify-plugin-build-sa"
  runnerServiceAccount: "dify-plugin-build-run-sa"
  imageRepoPrefix: "{account_id}.dkr.ecr.{region}.amazonaws.com/dify-ee"
  imageRepoType: ecr
  ecrRegion: "us-west-2"
```

#### **Step 4: Plugin Daemon のデータベース設定**

```bash theme={null}
externalPostgres:
  enabled: true
  address: "rds_address"
  port: "5432"
  credentials:
    plugin_daemon:
      database: "dify_plugin_daemon"
      username: "{user}"
      password: "{password}"
      sslmode: "disable"
    audit:
      database: "audit"
      username: "{user}"
      password: "{password}"
      sslmode: "disable"
```

#### **Step 5:** **リリースノートに従ってアップグレード（インストール）**

[https://langgenius.github.io/dify-helm/#/pages/3\_0\_0](https://langgenius.github.io/dify-helm/#/pages/3_0_0)

#### **Step 6: カスタム ServiceAccount に S3 権限を付与**

ServiceAccount 名: dify-plugin-connector-sa

```bash theme={null}
kubectl annotate serviceaccount -n {namespace} dify-plugin-connector-sa eks.amazonaws.com/role-arn={arn_of_IAM_S3}
```

もし ./irsa\_one\_click.sh を使って S3 読み書きロールを作成した場合、この ARN はスクリプト実行の最後に表示されます。

#### **Step 7: Dify Daemon Pod を再起動**

```bash theme={null}
kubectl delete pod {dify-plugin-daemon_name}
```

## **Notes**

* ❌ **Redis クラスターモードはサポートされていません**
* 🌐 EKS ノードはインターネットアクセスが可能になっている、または NAT Gateway の背後に配置されてインターネットに通じている必要があります
