java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.elasticloadbalancing.LoadBalancer
All Implemented Interfaces:
IResource, IConnectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:29.768Z") @Stability(Stable) public class LoadBalancer extends Resource implements IConnectable
A load balancer with a single listener.

Routes to a fleet of of instances in a VPC.

Example:

 Cluster cluster;
 TaskDefinition taskDefinition;
 Vpc vpc;
 Ec2Service service = Ec2Service.Builder.create(this, "Service").cluster(cluster).taskDefinition(taskDefinition).build();
 LoadBalancer lb = LoadBalancer.Builder.create(this, "LB").vpc(vpc).build();
 lb.addListener(LoadBalancerListener.builder().externalPort(80).build());
 lb.addTarget(service.loadBalancerTarget(LoadBalancerTargetOptions.builder()
         .containerName("MyContainer")
         .containerPort(80)
         .build()));
 
  • Constructor Details

    • LoadBalancer

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

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

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

    • addListener

      @Stability(Stable) @NotNull public ListenerPort addListener(@NotNull LoadBalancerListener listener)
      Add a backend to the load balancer.

      Parameters:
      listener - This parameter is required.
      Returns:
      A ListenerPort object that controls connections to the listener port
    • addTarget

      @Stability(Stable) public void addTarget(@NotNull ILoadBalancerTarget target)
      Parameters:
      target - This parameter is required.
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      Control all connections from and to this load balancer.
      Specified by:
      getConnections in interface IConnectable
    • getListenerPorts

      @Stability(Stable) @NotNull public List<ListenerPort> getListenerPorts()
      An object controlling specifically the connections for each listener added to this load balancer.
    • getLoadBalancerCanonicalHostedZoneName

      @Stability(Stable) @NotNull public String getLoadBalancerCanonicalHostedZoneName()
    • getLoadBalancerCanonicalHostedZoneNameId

      @Stability(Stable) @NotNull public String getLoadBalancerCanonicalHostedZoneNameId()
    • getLoadBalancerDnsName

      @Stability(Stable) @NotNull public String getLoadBalancerDnsName()
    • getLoadBalancerName

      @Stability(Stable) @NotNull public String getLoadBalancerName()
    • getLoadBalancerSourceSecurityGroupGroupName

      @Stability(Stable) @NotNull public String getLoadBalancerSourceSecurityGroupGroupName()
    • getLoadBalancerSourceSecurityGroupOwnerAlias

      @Stability(Stable) @NotNull public String getLoadBalancerSourceSecurityGroupOwnerAlias()