update cdk code

This commit is contained in:
nsxshota 2023-11-21 15:24:03 +09:00
commit 5d75376f2c
4 changed files with 15 additions and 7 deletions

View file

@ -78,7 +78,7 @@ export class BackEndCluster extends Construct {
"password": ecs.Secret.fromSecretsManager(secretsDB, 'password'),
},
});
this.backendServiceName = 'langflow-backend-service'
this.backendServiceName = 'backend'
const backendService = new ecs.FargateService(this, 'BackEndService', {
cluster: props.cluster,
serviceName: this.backendServiceName,

View file

@ -60,15 +60,16 @@ export class FrontEndCluster extends Construct {
{
containerPort: containerPort,
protocol: ecs.Protocol.TCP,
appProtocol:ecs.AppProtocol.http,
},
],
});
const frontendServiceName = 'langflow-frontend-service'
const frontendServiceName = 'frontend'
const frontendService = new ecs.FargateService(
this,
'FrontendService',
{
serviceName: 'langflow-frontend-service',
serviceName: frontendServiceName,
cluster: props.cluster,
desiredCount: 1,
assignPublicIp: false,

View file

@ -28,6 +28,9 @@ export class Network extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id)
const alb_listen_port=80
const front_service_port=3000
const back_service_port=7860
// VPC等リソースの作成
this.vpc = new ec2.Vpc(scope, 'VPC', {
@ -75,7 +78,7 @@ export class Network extends Construct {
description: 'for alb',
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',{
internetFacing: true, //インターネットからのアクセスを許可するかどうか指定
@ -84,10 +87,10 @@ export class Network extends Construct {
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', {
port: 3000,
port: front_service_port,
protocol: elb.ApplicationProtocol.HTTP,
healthCheck: {
enabled: true,
@ -114,7 +117,7 @@ export class Network extends Construct {
description: 'for langflow-back-ecs',
vpc: this.vpc,
})
this.ecsBackSG.addIngressRule(this.ecsFrontSG, ec2.Port.tcp(7860))
this.ecsBackSG.addIngressRule(this.ecsFrontSG, ec2.Port.tcp(back_service_port))
// RDSに設定するセキュリティグループ
this.dbSG = new ec2.SecurityGroup(scope, 'DBSecurityGroup', {
@ -150,6 +153,9 @@ export class Network extends Construct {
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
});
this.backendTaskRole.addToPolicy(ECSExecPolicyStatement);
// KendraとBedrockのアクセス権付与
// this.backendTaskRole.addToPolicy();
this.frontendTaskRole = new iam.Role(this, 'FrontendTaskRole', {
assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),

View file

@ -23,4 +23,5 @@ RUN chmod +x set_proxy.sh && \
USER node
RUN npm install --loglevel warn
RUN npm update
CMD ["npm", "run", "dev:docker"]