diff --git a/scripts/aws/README.md b/scripts/aws/README.md index 320efc02a..a7be98720 100644 --- a/scripts/aws/README.md +++ b/scripts/aws/README.md @@ -1,14 +1,43 @@ -# Welcome to your CDK TypeScript project +# Langflow on AWS -This is a blank project for CDK development with TypeScript. +Langflow on AWS は、 Langflow を AWS 上に展開する Project になります。 +この Branch では、AWS CDK を用いて 各種 Dockerfile からコンテナイメージを ECR に展開し、ECS、Aurora MySQL を用いて Langflow を構築します。 -The `cdk.json` file tells the CDK Toolkit how to execute your app. +# デプロイ +[CloudShell](https://us-east-1.console.aws.amazon.com/cloudshell/home?region=us-east-1)を開きます。 -## Useful commands +以下のコマンドを実行します。 +```shell +git clone https://github.com/aws-samples/cloud9-setup-for-prototyping +cd cloud9-setup-for-prototyping +./bin/bootstrap +``` -* `npm run build` compile typescript to js -* `npm run watch` watch for changes and compile -* `npm run test` perform the jest unit tests -* `cdk deploy` deploy this stack to your default AWS account/region -* `cdk diff` compare deployed stack with current state -* `cdk synth` emits the synthesized CloudFormation template +`Done!` と表示されたら [Cloud9](https://us-east-1.console.aws.amazon.com/cloud9control/home?region=us-east-1#/) から `cloud9-for-prototyping` を開きます。 +![make-cloud9](./img/langflow-cloud9.png) + +以下のコマンドを実行します。 + +```shell +git clone -b aws-cdk-dev2 https://github.com/kazuki306/langflow +cd langflow/scripts/aws +cp .env.example .env # この後envの設定が必要ならここで追記 +npm ci +cdk bootstrap +cdk deploy +``` +表示される URL にアクセスします。 +```shell +Outputs: +LangflowAppStack.NetworkURLXXXXXX = http://alb-XXXXXXXXXXX.elb.amazonaws.com +``` + +# 環境の削除 +`Cloud9` で以下のコマンドを実行します。 +```shell +cdk destroy +``` + + +[CloudFormation](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/getting-started)を開き、`aws-cloud9-cloud9-for-prototyping-XXXX` を選択して削除します。 +![delete-cfn](./img/langflow-cfn.png) \ No newline at end of file diff --git a/scripts/aws/img/langflow-cfn.png b/scripts/aws/img/langflow-cfn.png new file mode 100644 index 000000000..fecdeb70c Binary files /dev/null and b/scripts/aws/img/langflow-cfn.png differ diff --git a/scripts/aws/img/langflow-cloud9.png b/scripts/aws/img/langflow-cloud9.png new file mode 100644 index 000000000..5fd502353 Binary files /dev/null and b/scripts/aws/img/langflow-cloud9.png differ diff --git a/scripts/aws/lib/construct/backend.ts b/scripts/aws/lib/construct/backend.ts index 4ddff1e00..5c8540bdb 100644 --- a/scripts/aws/lib/construct/backend.ts +++ b/scripts/aws/lib/construct/backend.ts @@ -14,10 +14,6 @@ import * as dotenv from 'dotenv'; const path = require('path'); dotenv.config({path: path.join(__dirname, "../../.env")}); -console.log(process.env.LANGFLOW_AUTO_LOGIN); -console.log(process.env.LANGFLOW_SUPERUSER); -console.log(process.env.LANGFLOW_SUPERUSER_PASSWORD); - interface BackEndProps { cluster: ecs.Cluster ecsBackSG:ec2.SecurityGroup diff --git a/scripts/aws/lib/construct/network.ts b/scripts/aws/lib/construct/network.ts index aa9e48dc5..7dcfabaa0 100644 --- a/scripts/aws/lib/construct/network.ts +++ b/scripts/aws/lib/construct/network.ts @@ -1,4 +1,4 @@ -import { RemovalPolicy, Duration } from 'aws-cdk-lib' +import { RemovalPolicy, Duration, CfnOutput } from 'aws-cdk-lib' import { Construct } from 'constructs' import { aws_ec2 as ec2, @@ -76,9 +76,9 @@ export class Network extends Construct { }) this.albSG.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(alb_listen_port)) - this.alb = new elb.ApplicationLoadBalancer(this,'alb',{ + this.alb = new elb.ApplicationLoadBalancer(this,'langflow-alb',{ internetFacing: true, //インターネットからのアクセスを許可するかどうか指定 - loadBalancerName: 'alb', + loadBalancerName: 'langflow-alb', securityGroup: this.albSG, //作成したセキュリティグループを割り当てる vpc:this.vpc, }) @@ -127,13 +127,17 @@ export class Network extends Construct { // Create CloudWatch Log Group this.backendLogGroup = new logs.LogGroup(this, 'backendLogGroup', { - logGroupName: 'myapp-backend', + logGroupName: 'langflow-backend-logs', removalPolicy: RemovalPolicy.DESTROY, }); this.frontendLogGroup = new logs.LogGroup(this, 'frontendLogGroup', { - logGroupName: 'myapp-frontend', + logGroupName: 'langflow-frontend-logs', removalPolicy: RemovalPolicy.DESTROY, }); + + new CfnOutput(this, 'URL', { + value: `http://${this.alb.loadBalancerDnsName}`, + }); } } \ No newline at end of file