LoadBalancer¶
-
class
aws_cdk.aws_elasticloadbalancing.
LoadBalancer
(scope, id, *, vpc, cross_zone=None, health_check=None, internet_facing=None, listeners=None, subnet_selection=None, targets=None)¶ Bases:
aws_cdk.core.Resource
A load balancer with a single listener.
Routes to a fleet of of instances in a VPC.
- Parameters
scope (
Construct
) –id (
str
) –vpc (
IVpc
) – VPC network of the fleet instances.cross_zone (
Optional
[bool
]) – Whether cross zone load balancing is enabled. This controls whether the load balancer evenly distributes requests across each availability zone Default: truehealth_check (
Optional
[HealthCheck
]) – Health check settings for the load balancing targets. Not required but recommended. Default: - None.internet_facing (
Optional
[bool
]) – Whether this is an internet-facing Load Balancer. This controls whether the LB has a public IP address assigned. It does not open up the Load Balancer’s security groups to public internet access. Default: falselisteners (
Optional
[List
[LoadBalancerListener
]]) – What listeners to set up for the load balancer. Can also be added by .addListener() Default: -subnet_selection (
Optional
[SubnetSelection
]) – Which subnets to deploy the load balancer. Can be used to define a specific set of subnets to deploy the load balancer to. Useful multiple public or private subnets are covering the same availability zone. Default: - Public subnets if internetFacing, Private subnets otherwisetargets (
Optional
[List
[ILoadBalancerTarget
]]) – What targets to load balance to. Can also be added by .addTarget() Default: - None.
Methods
-
add_listener
(*, external_port, allow_connections_from=None, external_protocol=None, internal_port=None, internal_protocol=None, policy_names=None, ssl_certificate_id=None)¶ Add a backend to the load balancer.
- Parameters
external_port (
Union
[int
,float
]) – External listening port.allow_connections_from (
Optional
[List
[IConnectable
]]) – Allow connections to the load balancer from the given set of connection peers. By default, connections will be allowed from anywhere. Set this to an empty list to deny connections, or supply a custom list of peers to allow connections from (IP ranges or security groups). Default: Anywhereexternal_protocol (
Optional
[LoadBalancingProtocol
]) – What public protocol to use for load balancing. Either ‘tcp’, ‘ssl’, ‘http’ or ‘https’. May be omitted if the external port is either 80 or 443.internal_port (
Union
[int
,float
,None
]) – Instance listening port. Same as the externalPort if not specified. Default: externalPortinternal_protocol (
Optional
[LoadBalancingProtocol
]) – What public protocol to use for load balancing. Either ‘tcp’, ‘ssl’, ‘http’ or ‘https’. May be omitted if the internal port is either 80 or 443. The instance protocol is ‘tcp’ if the front-end protocol is ‘tcp’ or ‘ssl’, the instance protocol is ‘http’ if the front-end protocol is ‘https’.policy_names (
Optional
[List
[str
]]) – SSL policy names.ssl_certificate_id (
Optional
[str
]) – ID of SSL certificate.
- Return type
- Returns
A ListenerPort object that controls connections to the listener port
-
add_target
(target)¶ - Parameters
target (
ILoadBalancerTarget
) –- Return type
None
-
to_string
()¶ Returns a string representation of this construct.
- Return type
str
Attributes
-
connections
¶ Control all connections from and to this load balancer.
- Return type
-
env
¶ The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- Return type
-
listener_ports
¶ An object controlling specifically the connections for each listener added to this load balancer.
- Return type
List
[ListenerPort
]
-
load_balancer_canonical_hosted_zone_name
¶ true
- Type
attribute
- Return type
str
-
load_balancer_canonical_hosted_zone_name_id
¶ true
- Type
attribute
- Return type
str
-
load_balancer_dns_name
¶ true
- Type
attribute
- Return type
str
-
load_balancer_name
¶ true
- Type
attribute
- Return type
str
-
load_balancer_source_security_group_group_name
¶ true
- Type
attribute
- Return type
str
-
load_balancer_source_security_group_owner_alias
¶ true
- Type
attribute
- Return type
str
-
node
¶ The construct tree node associated with this construct.
- Return type
Static Methods
-
classmethod
is_construct
(x)¶ Return whether the given object is a Construct.
- Parameters
x (
Any
) –- Return type
bool