Skip to content

langgenius/aws-cdk-for-dify

Repository files navigation

Dify Enterprise on AWS

简体中文

Deploy Dify Enterprise on AWS using CDK.

1719058485616

Components

Testing Deployment

Component Helm Chart Value Count vCPU Memory (GB) Storage (GB) Notes
S3 persistence 1
Redis DB externalRedis 1 2 6.38
RDS Postgres DB externalPostgres 2 2 8
K8S Worker Node 1 4 16 100
EC2 (for Vector DB) vectorDB 1 4 8 100

Production Deployment

Component Helm Chart Value Count vCPU Memory (GB) Storage (GB) Notes
S3 persistence 1
Redis DB externalRedis 1 2 12.93
RDS Postgres DB externalPostgres 1 4 32
K8S Worker Node 6 8 32 100
EC2 (for Vector DB) vectorDB 3 16 64 100

Deployment

Prerequisites

  1. Install NodeJS Dependencies:

    npm install
  2. Configure AWS CLI:

    Install and configure the AWS CLI:

    aws configure
  3. Clone this repository:

    git clone https://github.com/langgenius/aws-cdk-for-dify.git
  4. Configure environment variables:

    cp env.example .env

    Modify the environment variable values in the .env file.

    Note:

    • If you are using the AWS China region, you need to configure the AWS_LOAD_BALANCER_REPO for proper functionality.
    • It is recommended to use an existing VPC for easier resource access.
  5. CDK Bootstrap:

    Initialize the CDK environment:

    npm run init
  6. CDK Deploy:

    • Deploy the Testing environment:

      npm run deploy-test
    • Deploy the Production environment:

      npm run deploy-prod
  7. Update AWS EKS Access Permissions:

    1. Navigate to the EKS Cluster panel, select the "Access" menu, and click on "Manage access": Dify-Testing-DifyStackTest-EKS
    2. In the "Manage access" dialog, select "EKS API and ConfigMap," then click "Save Changes."
    3. In the IAM Access Entries panel, click "Create access entry": IAM access entries
    4. Add your IAM user and assign the following permissions:
      • AmazonEKSAdminPolicy
      • AmazonEKSAdminViewPolicy
      • AmazonEKSClusterAdminPolicy
  8. Configure kubeconfig to access the K8S cluster locally:

    aws eks update-kubeconfig --region <cn-northwest-1> --name <Dify-Testing-DifyStackTest-EKS>

    Adjust the region and name according to your deployment:

    • region: The deployment region.
    • name: The EKS cluster name (Dify-Testing-DifyStackTest-EKS | Dify-Production-DifyStackProd-EKS).
  9. CDK Destroy:

    To destroy the stack:

    npm run destroy