スキップしてコンテンツを表示

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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ