AWS CDK:负载平衡器侦听器转发给ECS
我正在用CDK(打字稿)代替控制台定义的基础架构。
我需要知道如何将通信转发到端口80到ECS任务。
在控制台中,我在目标组中设置了ECS任务的IP地址。
以同样的方式,我如何将负载平衡器与CDK中的EC相关联?
也许这样做的唯一方法是用L1代码编写它? (cfntargetGroup
类?)
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true
})
lb.addListener('Listener', {
port: 80,
defaultTargetGroups: [] // pass something here?
})
I am replacing the infrastructure defined in the console with CDK(TypeScript).
I need to know how to forward the communication to port 80 to the ECS task.
In the console, I set the IP address of the ECS task in the Target groups.
In the same way, how can I associate the Load Balancer with ECS in CDK?
Perhaps the only way to do this is to write it in L1 code? (CfnTargetGroup
class?)
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc,
internetFacing: true
})
lb.addListener('Listener', {
port: 80,
defaultTargetGroups: [] // pass something here?
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选项1:将听众添加到ALB。将ECS服务添加为侦听器目标。完整示例在这里。
选项2:使用L3 applicationloadbalancedfargateservice 或其 aws_ecs_patterns 在ALB后面创建ECS服务。
Option 1: Add a listener to the ALB. Add the ECS Service as a listener target. Full example here.
Option 2: Use the L3 ApplicationLoadBalancedFargateService or its EC2 cousin from aws_ecs_patterns to create an ECS Service behind an ALB.