跳至内容

How would I specify the subnets for an ALB created by ApplicationLoadBalancedFargateService?

0

I'm using the ApplicationLoadBalancedFargateService construct to deploy ECS services. I have a new requirement to specify the subnets where the tasks and ALBs are instantiated. Tasks were easy with taskSubnets property on ApplicationLoadBalancedFargateServiceProps, however I can't seem to find a way to specify subnets for the ALBs. The construct is currently placing an ALB on each public subnet, which I don't want in this case.

Any suggestions?

Many Thanks, Bryan

1 回答
0

Hello.

How about specifying your own ALB with the parameter "loadBalancer"?
I thought that if you created your own ALB, you could choose any subnet you like.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedFargateService.html

The code will look like this:

    const loadBalancedFargateService = new ecsp.ApplicationLoadBalancedFargateService(this, 'SampleWebService', {
      cluster,
      memoryLimitMiB:512,
      desiredCount:1,
      cpu:256,
      taskImageOptions: {
        image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
      loadBalancer:alb, // <-- your ALB
      openListener:false,
    });
专家

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。