Class AlbListenerTarget
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();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.elasticloadbalancingv2.INetworkLoadBalancerTarget
INetworkLoadBalancerTarget.Jsii$Default, INetworkLoadBalancerTarget.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionAlbListenerTarget
(ApplicationListener albListener) Create a new ALB target.protected
AlbListenerTarget
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
AlbListenerTarget
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionattachToNetworkTargetGroup
(INetworkTargetGroup targetGroup) Register this ALB target with a load balancer.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
AlbListenerTarget
protected AlbListenerTarget(software.amazon.jsii.JsiiObjectRef objRef) -
AlbListenerTarget
protected AlbListenerTarget(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
AlbListenerTarget
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
-
attachToNetworkTargetGroup
@Stability(Stable) @NotNull public LoadBalancerTargetProps attachToNetworkTargetGroup(@NotNull INetworkTargetGroup targetGroup) Register this ALB target with a load balancer.Don't call this, it is called automatically when you add the target to a load balancer.
This adds dependency on albListener because creation of ALB listener and NLB can vary during runtime. More Details on - https://github.com/aws/aws-cdk/issues/17208
- Specified by:
attachToNetworkTargetGroup
in interfaceINetworkLoadBalancerTarget
- Overrides:
attachToNetworkTargetGroup
in classAlbArnTarget
- Parameters:
targetGroup
- This parameter is required.
-