Fix bug in deployment procedure in AWS CDK and support HTTPS (#1491)

* add cloudfront

* modify: healthcheck disable

* modify: health check option

* modify nodejsbuild

* add nodejs version

* endpoint configuration

* set axios url

* remote console.log VITE_PROXY_TARGET

* create alb stack

* add alb to origin

* alb build success

* remote baseURL setting

* add redirect

* change responseHttpStatus to 200

* modify output and readme

* modify architecture

* add health check path route to cloudfront routing

* modified: c9 env name in deploy langflow section

* modified : package dependency for pymysql

* modified: deploy procedure

* modified: deploy procedure (ja)

---------

Co-authored-by: nsxshota <nsxshota@amazon.co.jp>
Co-authored-by: ymkazuki <ymkazuki@amazon.co.jp>
Co-authored-by: Shota Nakamoto <53632932+nsy0328@users.noreply.github.com>
This commit is contained in:
kazuki306 2024-03-04 20:50:51 +09:00 • committed by GitHub
commit 3eeda84d28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 678 additions and 271 deletions

View file

@ -11,20 +11,16 @@ import {
export class Network extends Construct {
readonly vpc: ec2.Vpc;
readonly cluster: ecs.Cluster;
readonly alb: elb.IApplicationLoadBalancer;
readonly targetGroup: elb.ApplicationTargetGroup;
readonly cloudmapNamespace: servicediscovery.PrivateDnsNamespace;
readonly ecsFrontSG: ec2.SecurityGroup;
readonly ecsBackSG: ec2.SecurityGroup;
readonly dbSG: ec2.SecurityGroup;
readonly albSG: ec2.SecurityGroup;
readonly backendLogGroup: logs.LogGroup;
readonly frontendLogGroup: logs.LogGroup;
readonly alb: elb.IApplicationLoadBalancer;
readonly albTG: elb.ApplicationTargetGroup;
readonly albSG: ec2.SecurityGroup;
constructor(scope: Construct, id: string) {
super(scope, id)
const alb_listen_port=80
const front_service_port=3000
const back_service_port=7860
// VPC等リソースの作成
@ -51,22 +47,6 @@ export class Network extends Construct {
],
natGateways: 1,
})
// Cluster
this.cluster = new ecs.Cluster(this, 'EcsCluster', {
clusterName: 'langflow-cluster',
vpc: this.vpc,
enableFargateCapacityProviders: true,
});
// Private DNS
this.cloudmapNamespace = new servicediscovery.PrivateDnsNamespace(
this,
'Namespace',
{
name: 'ecs-deploy.com',
vpc: this.vpc,
}
);
// ALBに設定するセキュリティグループ
this.albSG = new ec2.SecurityGroup(scope, 'ALBSecurityGroup', {
@ -74,7 +54,6 @@ export class Network extends Construct {
description: 'for alb',
vpc: this.vpc,
})
this.albSG.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(alb_listen_port))
this.alb = new elb.ApplicationLoadBalancer(this,'langflow-alb',{
internetFacing: true, //インターネットからのアクセスを許可するかどうか指定
@ -85,8 +64,8 @@ export class Network extends Construct {
const listener = this.alb.addListener('Listener', { port: alb_listen_port });
this.targetGroup = listener.addTargets('targetGroup', {
port: front_service_port,
this.albTG = listener.addTargets('targetGroup', {
port: back_service_port,
protocol: elb.ApplicationProtocol.HTTP,
healthCheck: {
enabled: true,
@ -99,13 +78,12 @@ export class Network extends Construct {
},
});
// ECS FrontEndに設定するセキュリティグループ
this.ecsFrontSG = new ec2.SecurityGroup(scope, 'ECSFrontEndSecurityGroup', {
securityGroupName: 'langflow-ecs-front-sg',
description: 'for langflow-front-ecs',
// Cluster
this.cluster = new ecs.Cluster(this, 'EcsCluster', {
clusterName: 'langflow-cluster',
vpc: this.vpc,
})
this.ecsFrontSG.addIngressRule(this.albSG, ec2.Port.allTcp())
enableFargateCapacityProviders: true,
});
// ECS BackEndに設定するセキュリティグループ
this.ecsBackSG = new ec2.SecurityGroup(scope, 'ECSBackEndSecurityGroup', {
@ -113,7 +91,7 @@ export class Network extends Construct {
description: 'for langflow-back-ecs',
vpc: this.vpc,
})
this.ecsBackSG.addIngressRule(this.ecsFrontSG, ec2.Port.tcp(back_service_port))
this.ecsBackSG.addIngressRule(this.albSG,ec2.Port.tcp(back_service_port))
// RDSに設定するセキュリティグループ
this.dbSG = new ec2.SecurityGroup(scope, 'DBSecurityGroup', {
@ -122,7 +100,7 @@ export class Network extends Construct {
description: 'for langflow-db',
vpc: this.vpc,
})
// AppRunnerSecurityGroupからのポート3306:mysql(5432:postgres)のインバウンドを許可
// langflow-ecs-back-sg からのポート3306:mysql(5432:postgres)のインバウンドを許可
this.dbSG.addIngressRule(this.ecsBackSG, ec2.Port.tcp(3306))
// Create CloudWatch Log Group
@ -131,13 +109,5 @@ export class Network extends Construct {
removalPolicy: RemovalPolicy.DESTROY,
});
this.frontendLogGroup = new logs.LogGroup(this, 'frontendLogGroup', {
logGroupName: 'langflow-frontend-logs',
removalPolicy: RemovalPolicy.DESTROY,
});
new CfnOutput(this, 'URL', {
value: `http://${this.alb.loadBalancerDnsName}`,
});
}
}