add Cfn Output & Readme

This commit is contained in:
nsxshota 2023-12-01 12:09:31 +09:00
commit fde4897493
5 changed files with 48 additions and 19 deletions

View file

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -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

View file

@ -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}`,
});
}
}