내용으로 건너뛰기

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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠