java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.elasticloadbalancingv2.targets.AlbArnTarget
software.amazon.awscdk.services.elasticloadbalancingv2.targets.AlbListenerTarget
All Implemented Interfaces:
INetworkLoadBalancerTarget, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-06T14:43:19.081Z") @Stability(Stable) public class AlbListenerTarget extends AlbArnTarget
A single Application Load Balancer's listener as the target for load balancing.

Example:

 import software.amazon.awscdk.services.elasticloadbalancingv2.targets.*;
 import software.amazon.awscdk.services.ecs.*;
 import software.amazon.awscdk.services.ecs.patterns.*;
 Vpc vpc;
 FargateTaskDefinition task = FargateTaskDefinition.Builder.create(this, "Task").cpu(256).memoryLimitMiB(512).build();
 task.addContainer("nginx", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("public.ecr.aws/nginx/nginx:latest"))
         .portMappings(List.of(PortMapping.builder().containerPort(80).build()))
         .build());
 ApplicationLoadBalancedFargateService svc = ApplicationLoadBalancedFargateService.Builder.create(this, "Service")
         .vpc(vpc)
         .taskDefinition(task)
         .publicLoadBalancer(false)
         .build();
 NetworkLoadBalancer nlb = NetworkLoadBalancer.Builder.create(this, "Nlb")
         .vpc(vpc)
         .crossZoneEnabled(true)
         .internetFacing(true)
         .build();
 NetworkListener listener = nlb.addListener("listener", BaseNetworkListenerProps.builder().port(80).build());
 listener.addTargets("Targets", AddNetworkTargetsProps.builder()
         .targets(List.of(new AlbListenerTarget(svc.getListener())))
         .port(80)
         .build());
 CfnOutput.Builder.create(this, "NlbEndpoint").value(String.format("http://%s", nlb.getLoadBalancerDnsName())).build();
 
  • Constructor Details

    • AlbListenerTarget

      protected AlbListenerTarget(software.amazon.jsii.JsiiObjectRef objRef)
    • AlbListenerTarget

      protected AlbListenerTarget(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • AlbListenerTarget

      @Stability(Stable) public AlbListenerTarget(@NotNull ApplicationListener albListener)
      Create a new ALB target.

      The associated target group will automatically have a dependency added against the ALB's listener.

      Parameters:
      albListener - The application load balancer listener to target. This parameter is required.
  • Method Details