update cdk code
This commit is contained in:
parent
58726b15c5
commit
5d75376f2c
4 changed files with 15 additions and 7 deletions
|
|
@ -78,7 +78,7 @@ export class BackEndCluster extends Construct {
|
||||||
"password": ecs.Secret.fromSecretsManager(secretsDB, 'password'),
|
"password": ecs.Secret.fromSecretsManager(secretsDB, 'password'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.backendServiceName = 'langflow-backend-service'
|
this.backendServiceName = 'backend'
|
||||||
const backendService = new ecs.FargateService(this, 'BackEndService', {
|
const backendService = new ecs.FargateService(this, 'BackEndService', {
|
||||||
cluster: props.cluster,
|
cluster: props.cluster,
|
||||||
serviceName: this.backendServiceName,
|
serviceName: this.backendServiceName,
|
||||||
|
|
|
||||||
|
|
@ -60,15 +60,16 @@ export class FrontEndCluster extends Construct {
|
||||||
{
|
{
|
||||||
containerPort: containerPort,
|
containerPort: containerPort,
|
||||||
protocol: ecs.Protocol.TCP,
|
protocol: ecs.Protocol.TCP,
|
||||||
|
appProtocol:ecs.AppProtocol.http,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const frontendServiceName = 'langflow-frontend-service'
|
const frontendServiceName = 'frontend'
|
||||||
const frontendService = new ecs.FargateService(
|
const frontendService = new ecs.FargateService(
|
||||||
this,
|
this,
|
||||||
'FrontendService',
|
'FrontendService',
|
||||||
{
|
{
|
||||||
serviceName: 'langflow-frontend-service',
|
serviceName: frontendServiceName,
|
||||||
cluster: props.cluster,
|
cluster: props.cluster,
|
||||||
desiredCount: 1,
|
desiredCount: 1,
|
||||||
assignPublicIp: false,
|
assignPublicIp: false,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ export class Network extends Construct {
|
||||||
|
|
||||||
constructor(scope: Construct, id: string) {
|
constructor(scope: Construct, id: string) {
|
||||||
super(scope, id)
|
super(scope, id)
|
||||||
|
const alb_listen_port=80
|
||||||
|
const front_service_port=3000
|
||||||
|
const back_service_port=7860
|
||||||
|
|
||||||
// VPC等リソースの作成
|
// VPC等リソースの作成
|
||||||
this.vpc = new ec2.Vpc(scope, 'VPC', {
|
this.vpc = new ec2.Vpc(scope, 'VPC', {
|
||||||
|
|
@ -75,7 +78,7 @@ export class Network extends Construct {
|
||||||
description: 'for alb',
|
description: 'for alb',
|
||||||
vpc: this.vpc,
|
vpc: this.vpc,
|
||||||
})
|
})
|
||||||
this.albSG.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(80))
|
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,'alb',{
|
||||||
internetFacing: true, //インターネットからのアクセスを許可するかどうか指定
|
internetFacing: true, //インターネットからのアクセスを許可するかどうか指定
|
||||||
|
|
@ -84,10 +87,10 @@ export class Network extends Construct {
|
||||||
vpc:this.vpc,
|
vpc:this.vpc,
|
||||||
})
|
})
|
||||||
|
|
||||||
const listener = this.alb.addListener('Listener', { port: 80 });
|
const listener = this.alb.addListener('Listener', { port: alb_listen_port });
|
||||||
|
|
||||||
this.targetGroup = listener.addTargets('targetGroup', {
|
this.targetGroup = listener.addTargets('targetGroup', {
|
||||||
port: 3000,
|
port: front_service_port,
|
||||||
protocol: elb.ApplicationProtocol.HTTP,
|
protocol: elb.ApplicationProtocol.HTTP,
|
||||||
healthCheck: {
|
healthCheck: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
@ -114,7 +117,7 @@ export class Network extends Construct {
|
||||||
description: 'for langflow-back-ecs',
|
description: 'for langflow-back-ecs',
|
||||||
vpc: this.vpc,
|
vpc: this.vpc,
|
||||||
})
|
})
|
||||||
this.ecsBackSG.addIngressRule(this.ecsFrontSG, ec2.Port.tcp(7860))
|
this.ecsBackSG.addIngressRule(this.ecsFrontSG, ec2.Port.tcp(back_service_port))
|
||||||
|
|
||||||
// RDSに設定するセキュリティグループ
|
// RDSに設定するセキュリティグループ
|
||||||
this.dbSG = new ec2.SecurityGroup(scope, 'DBSecurityGroup', {
|
this.dbSG = new ec2.SecurityGroup(scope, 'DBSecurityGroup', {
|
||||||
|
|
@ -150,6 +153,9 @@ export class Network extends Construct {
|
||||||
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
|
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
|
||||||
});
|
});
|
||||||
this.backendTaskRole.addToPolicy(ECSExecPolicyStatement);
|
this.backendTaskRole.addToPolicy(ECSExecPolicyStatement);
|
||||||
|
// KendraとBedrockのアクセス権付与
|
||||||
|
// this.backendTaskRole.addToPolicy();
|
||||||
|
|
||||||
|
|
||||||
this.frontendTaskRole = new iam.Role(this, 'FrontendTaskRole', {
|
this.frontendTaskRole = new iam.Role(this, 'FrontendTaskRole', {
|
||||||
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
|
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,5 @@ RUN chmod +x set_proxy.sh && \
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
RUN npm install --loglevel warn
|
RUN npm install --loglevel warn
|
||||||
|
RUN npm update
|
||||||
CMD ["npm", "run", "dev:docker"]
|
CMD ["npm", "run", "dev:docker"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue