Class NetworkLoadBalancer

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.elasticloadbalancingv2.BaseLoadBalancer
software.amazon.awscdk.services.elasticloadbalancingv2.NetworkLoadBalancer
All Implemented Interfaces:
IResource, IConnectable, IVpcEndpointServiceLoadBalancer, ILoadBalancerV2, INetworkLoadBalancer, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:24:01.745Z") @Stability(Stable) public class NetworkLoadBalancer extends BaseLoadBalancer implements INetworkLoadBalancer
Define a new network load balancer.

Example:

 import software.amazon.awscdk.aws_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

    • NetworkLoadBalancer

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

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

      @Stability(Stable) public NetworkLoadBalancer(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull NetworkLoadBalancerProps 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 INetworkLoadBalancer fromLookup(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull NetworkLoadBalancerLookupOptions options)
      Looks up the network load balancer.

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

      @Stability(Stable) @NotNull public static INetworkLoadBalancer fromNetworkLoadBalancerAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull NetworkLoadBalancerAttributes attrs)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addListener

      @Stability(Stable) @NotNull public NetworkListener addListener(@NotNull String id, @NotNull BaseNetworkListenerProps props)
      Add a listener to this load balancer.

      Specified by:
      addListener in interface INetworkLoadBalancer
      Parameters:
      id - This parameter is required.
      props - This parameter is required.
      Returns:
      The newly created listener
    • addSecurityGroup

      @Stability(Stable) public void addSecurityGroup(@NotNull ISecurityGroup securityGroup)
      Add a security group to this load balancer.

      Parameters:
      securityGroup - This parameter is required.
    • metric

      @Stability(Deprecated) @Deprecated @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.custom instead
      (deprecated) Return the given named metric for this Network Load Balancer.

      Default: Average over 5 minutes

      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Deprecated) @Deprecated @NotNull public Metric metric(@NotNull String metricName)
      Deprecated.
      Use NetworkLoadBalancer.metrics.custom instead
      (deprecated) Return the given named metric for this Network Load Balancer.

      Default: Average over 5 minutes

      Parameters:
      metricName - This parameter is required.
    • metricActiveFlowCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricActiveFlowCount(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.activeFlowCount instead
      (deprecated) The total number of concurrent TCP flows (or connections) from clients to targets.

      This metric includes connections in the SYN_SENT and ESTABLISHED states. TCP connections are not terminated at the load balancer, so a client opening a TCP connection to a target counts as a single flow.

      Default: Average over 5 minutes

      Parameters:
      props -
    • metricActiveFlowCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricActiveFlowCount()
      Deprecated.
      Use NetworkLoadBalancer.metrics.activeFlowCount instead
      (deprecated) The total number of concurrent TCP flows (or connections) from clients to targets.

      This metric includes connections in the SYN_SENT and ESTABLISHED states. TCP connections are not terminated at the load balancer, so a client opening a TCP connection to a target counts as a single flow.

      Default: Average over 5 minutes

    • metricConsumedLCUs

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricConsumedLCUs(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.activeFlowCount instead
      (deprecated) The number of load balancer capacity units (LCU) used by your load balancer.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricConsumedLCUs

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricConsumedLCUs()
      Deprecated.
      Use NetworkLoadBalancer.metrics.activeFlowCount instead
      (deprecated) The number of load balancer capacity units (LCU) used by your load balancer.

      Default: Sum over 5 minutes

    • metricNewFlowCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricNewFlowCount(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.newFlowCount instead
      (deprecated) The total number of new TCP flows (or connections) established from clients to targets in the time period.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricNewFlowCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricNewFlowCount()
      Deprecated.
      Use NetworkLoadBalancer.metrics.newFlowCount instead
      (deprecated) The total number of new TCP flows (or connections) established from clients to targets in the time period.

      Default: Sum over 5 minutes

    • metricProcessedBytes

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricProcessedBytes(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.processedBytes instead
      (deprecated) The total number of bytes processed by the load balancer, including TCP/IP headers.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricProcessedBytes

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricProcessedBytes()
      Deprecated.
      Use NetworkLoadBalancer.metrics.processedBytes instead
      (deprecated) The total number of bytes processed by the load balancer, including TCP/IP headers.

      Default: Sum over 5 minutes

    • metricTcpClientResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpClientResetCount(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpClientResetCount instead
      (deprecated) The total number of reset (RST) packets sent from a client to a target.

      These resets are generated by the client and forwarded by the load balancer.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricTcpClientResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpClientResetCount()
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpClientResetCount instead
      (deprecated) The total number of reset (RST) packets sent from a client to a target.

      These resets are generated by the client and forwarded by the load balancer.

      Default: Sum over 5 minutes

    • metricTcpElbResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpElbResetCount(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpElbResetCount instead
      (deprecated) The total number of reset (RST) packets generated by the load balancer.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricTcpElbResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpElbResetCount()
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpElbResetCount instead
      (deprecated) The total number of reset (RST) packets generated by the load balancer.

      Default: Sum over 5 minutes

    • metricTcpTargetResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpTargetResetCount(@Nullable MetricOptions props)
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpTargetResetCount instead
      (deprecated) The total number of reset (RST) packets sent from a target to a client.

      These resets are generated by the target and forwarded by the load balancer.

      Default: Sum over 5 minutes

      Parameters:
      props -
    • metricTcpTargetResetCount

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricTcpTargetResetCount()
      Deprecated.
      Use NetworkLoadBalancer.metrics.tcpTargetResetCount instead
      (deprecated) The total number of reset (RST) packets sent from a target to a client.

      These resets are generated by the target and forwarded by the load balancer.

      Default: Sum over 5 minutes

    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      The network connections associated with this resource.
      Specified by:
      getConnections in interface IConnectable
    • getMetrics

      @Stability(Stable) @NotNull public INetworkLoadBalancerMetrics getMetrics()
      All metrics available for this load balancer.
      Specified by:
      getMetrics in interface INetworkLoadBalancer
    • getEnforceSecurityGroupInboundRulesOnPrivateLinkTraffic

      @Stability(Stable) @Nullable public String getEnforceSecurityGroupInboundRulesOnPrivateLinkTraffic()
      Indicates whether to evaluate inbound security group rules for traffic sent to a Network Load Balancer through AWS PrivateLink.
      Specified by:
      getEnforceSecurityGroupInboundRulesOnPrivateLinkTraffic in interface INetworkLoadBalancer
    • getIpAddressType

      @Stability(Stable) @Nullable public IpAddressType getIpAddressType()
      The type of IP addresses to use.
      Specified by:
      getIpAddressType in interface INetworkLoadBalancer
    • getSecurityGroups

      @Stability(Stable) @Nullable public List<String> getSecurityGroups()
      After the implementation of IConnectable (see https://github.com/aws/aws-cdk/pull/28494), the default value for securityGroups is set by the ec2.Connections constructor to an empty array. To keep backward compatibility (securityGroups is undefined if the related property is not specified) a getter has been added.
      Specified by:
      getSecurityGroups in interface INetworkLoadBalancer