java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.globalaccelerator.Listener
All Implemented Interfaces:
IResource, IListener, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.94.0 (build b380f01)", date="2024-03-14T22:21:55.945Z") @Stability(Stable) public class Listener extends Resource implements IListener
The construct for the Listener.

Example:

 // Create an Accelerator
 Accelerator accelerator = new Accelerator(this, "Accelerator");
 // Create a Listener
 Listener listener = accelerator.addListener("Listener", ListenerOptions.builder()
         .portRanges(List.of(PortRange.builder().fromPort(80).build(), PortRange.builder().fromPort(443).build()))
         .build());
 // Import the Load Balancers
 INetworkLoadBalancer nlb1 = NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, "NLB1", NetworkLoadBalancerAttributes.builder()
         .loadBalancerArn("arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b")
         .build());
 INetworkLoadBalancer nlb2 = NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, "NLB2", NetworkLoadBalancerAttributes.builder()
         .loadBalancerArn("arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1")
         .build());
 // Add one EndpointGroup for each Region we are targeting
 listener.addEndpointGroup("Group1", EndpointGroupOptions.builder()
         .endpoints(List.of(new NetworkLoadBalancerEndpoint(nlb1)))
         .build());
 listener.addEndpointGroup("Group2", EndpointGroupOptions.builder()
         // Imported load balancers automatically calculate their Region from the ARN.
         // If you are load balancing to other resources, you must also pass a `region`
         // parameter here.
         .endpoints(List.of(new NetworkLoadBalancerEndpoint(nlb2)))
         .build());
 
  • Constructor Details

    • Listener

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

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

      @Stability(Stable) public Listener(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ListenerProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromListenerArn

      @Stability(Stable) @NotNull public static IListener fromListenerArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String listenerArn)
      import from ARN.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      listenerArn - This parameter is required.
    • addEndpointGroup

      @Stability(Stable) @NotNull public EndpointGroup addEndpointGroup(@NotNull String id, @Nullable EndpointGroupOptions options)
      Add a new endpoint group to this listener.

      Parameters:
      id - This parameter is required.
      options -
    • addEndpointGroup

      @Stability(Stable) @NotNull public EndpointGroup addEndpointGroup(@NotNull String id)
      Add a new endpoint group to this listener.

      Parameters:
      id - This parameter is required.
    • getListenerArn

      @Stability(Stable) @NotNull public String getListenerArn()
      The ARN of the listener.
      Specified by:
      getListenerArn in interface IListener
    • getListenerName

      @Stability(Stable) @NotNull public String getListenerName()
      The name of the listener.