Saltar al contenido

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 Respuesta
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,
    });
EXPERTO

respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.