java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IConstruct, IDependable, IResource, INetworkListener, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:44.358Z") @Stability(Stable) public class NetworkListener extends BaseListener implements INetworkListener
Define a Network Listener.

Example:

 import software.amazon.awscdk.services.apigatewayv2.integrations.HttpNlbIntegration;
 Vpc vpc = new Vpc(this, "VPC");
 NetworkLoadBalancer lb = NetworkLoadBalancer.Builder.create(this, "lb").vpc(vpc).build();
 NetworkListener listener = lb.addListener("listener", BaseNetworkListenerProps.builder().port(80).build());
 listener.addTargets("target", AddNetworkTargetsProps.builder()
         .port(80)
         .build());
 HttpApi httpEndpoint = HttpApi.Builder.create(this, "HttpProxyPrivateApi")
         .defaultIntegration(new HttpNlbIntegration("DefaultIntegration", listener))
         .build();
 
  • Constructor Details

    • NetworkListener

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

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

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

    • fromLookup

      @Stability(Stable) @NotNull public static INetworkListener fromLookup(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull NetworkListenerLookupOptions options)
      Looks up a network listener.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      options - This parameter is required.
    • fromNetworkListenerArn

      @Stability(Stable) @NotNull public static INetworkListener fromNetworkListenerArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String networkListenerArn)
      Import an existing listener.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      networkListenerArn - This parameter is required.
    • addAction

      @Stability(Stable) public void addAction(@NotNull String _id, @NotNull AddNetworkActionProps props)
      Perform the given Action on incoming requests.

      This allows full control of the default Action of the load balancer, including weighted forwarding. See the NetworkListenerAction class for all options.

      Parameters:
      _id - This parameter is required.
      props - This parameter is required.
    • addCertificates

      @Stability(Stable) public void addCertificates(@NotNull String id, @NotNull List<IListenerCertificate> certificates)
      Add one or more certificates to this listener.

      After the first certificate, this creates NetworkListenerCertificates resources since cloudformation requires the certificates array on the listener resource to have a length of 1.

      Parameters:
      id - This parameter is required.
      certificates - This parameter is required.
    • addTargetGroups

      @Stability(Stable) public void addTargetGroups(@NotNull String _id, @NotNull @NotNull INetworkTargetGroup... targetGroups)
      Load balance incoming requests to the given target groups.

      All target groups will be load balanced to with equal weight and without stickiness. For a more complex configuration than that, use addAction().

      Parameters:
      _id - This parameter is required.
      targetGroups - This parameter is required.
    • addTargets

      @Stability(Stable) @NotNull public NetworkTargetGroup addTargets(@NotNull String id, @NotNull AddNetworkTargetsProps props)
      Load balance incoming requests to the given load balancing targets.

      This method implicitly creates a NetworkTargetGroup for the targets involved, and a 'forward' action to route traffic to the given TargetGroup.

      If you want more control over the precise setup, create the TargetGroup and use addAction yourself.

      It's possible to add conditions to the targets added in this way. At least one set of targets must be added without conditions.

      Parameters:
      id - This parameter is required.
      props - This parameter is required.
      Returns:
      The newly created target group
    • getLoadBalancer

      @Stability(Stable) @NotNull public INetworkLoadBalancer getLoadBalancer()
      The load balancer this listener is attached to.