Skip to content

mabuchs/dify-on-aws-cdk-with-cognito

 
 

Repository files navigation

Dify on AWS with CDK

Build

Deploy Dify, an LLM app development platform, using AWS managed services with AWS CDK.

architecture

Key Features:

  • Fully managed services requiring less maintenance effort
    • Aurora servereless v2, ElastiCache, ECS Fargate, etc.
  • Cost effective architectural decisions
    • allow to use NAT instances instead of NAT Gateway, and Fargate spot capacity by default
  • Natively integrate with Bedrock using IAM roles

本リポジトリの使い方について、日本語で書かれた記事があります!AWS CDKでDifyを一撃構築

Prerequisites

You must have the following dependencies installed to deploy this app:

Deploy

You can adjust configuration parameters such as AWS regions by modifying bin/cdk.ts. Please also check DifyOnAwsStackProps interface for all the available parameters.

Then you can run the following commands to deploy the entire stack.

# install npm dependencies
npm ci
# bootstrap the AWS account (required only once per account and region)
npx cdk bootstrap
# deploy the CDK stack
npx cdk deploy

The initial deployment usually takes about 20 minutes. After a successful deployment, you will get the URL for the app.

 ✅  DifyOnAwsCdkStack

✨  Deployment time: 326.43s

Outputs:
DifyOnAwsCdkStack.ApiGatewayApiEndpoint015055E7 = https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com

You can open the URL with a browser and get started!

Setup Dify to use Bedrock

After logged in, you can setup Dify to use Bedrock LLMs.

Important

Before setting up models in Dify, you have to enable models you want to use in Bedrock management console. Please read this document for more details.

Go to settings by clicking the right-top profile, click WORKSPACE -> Model Provider, and select AWS Bedrock model.

IAM policies are already configured properly, so you can just select a correct AWS region (where the models are enabled) to use Bedrock models, and click Save.

model-setup

Clean up

To avoid incurring future charges, clean up the resources you created.

npx cdk destroy --force
# If you encountered an error during the deletion, please retry. It happens sometimes.

License

All the code in this repository is MIT-licensed. However, you should also check Dify's license.

Acknowledgement

This CDK code is heavily inspired by dify-aws-terraform.

About

Dify on AWS **with Cognito Authentication**

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.2%
  • JavaScript 1.5%
  • Dockerfile 0.3%