LoadBalancerListener Struct
Add a backend to the load balancer.
| Source | aws-elasticloadbalancing/lib/load-balancer.ts |
|---|
Example
ts
declare const vpc: ec2.IVpc;
const lb = new elb.LoadBalancer(this, 'LB', {
vpc,
internetFacing: true,
healthCheck: {
port: 80,
},
});
declare const myAutoScalingGroup: autoscaling.AutoScalingGroup;
lb.addTarget(myAutoScalingGroup);
lb.addListener({
externalPort: 80,
});
python
# vpc: ec2.IVpc
# my_auto_scaling_group: autoscaling.AutoScalingGroup
lb = elb.LoadBalancer(self, "LB",
vpc=vpc,
internet_facing=True,
health_check=elb.HealthCheck(
port=80
)
)
lb.add_target(my_auto_scaling_group)
lb.add_listener(
external_port=80
)
java
IVpc vpc;
AutoScalingGroup myAutoScalingGroup;
LoadBalancer lb = LoadBalancer.Builder.create(this, "LB")
.vpc(vpc)
.internetFacing(true)
.healthCheck(HealthCheck.builder()
.port(80)
.build())
.build();
lb.addTarget(myAutoScalingGroup);
lb.addListener(LoadBalancerListener.builder()
.externalPort(80)
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
IVpc vpc;
AutoScalingGroup myAutoScalingGroup;
var lb = new LoadBalancer(this, "LB", new LoadBalancerProps {
Vpc = vpc,
InternetFacing = true,
HealthCheck = new HealthCheck {
Port = 80
}
});
lb.AddTarget(myAutoScalingGroup);
lb.AddListener(new LoadBalancerListener {
ExternalPort = 80
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc IVpc
var myAutoScalingGroup AutoScalingGroup
lb := elb.NewLoadBalancer(this, jsii.String("LB"), &LoadBalancerProps{
Vpc: Vpc,
InternetFacing: jsii.Boolean(true),
HealthCheck: &HealthCheck{
Port: jsii.Number(80),
},
})
lb.AddTarget(myAutoScalingGroup)
lb.AddListener(&LoadBalancerListener{
ExternalPort: jsii.Number(80),
})
Properties
allowConnectionsFromoptionalIConnectable[]allow_connections_fromoptionaltyping.List[IConnectable]allowConnectionsFromoptionalList<IConnectable>AllowConnectionsFromoptionalIConnectable[]AllowConnectionsFromoptional*[]IConnectable = Anywhere #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).
externalPortnumberexternal_portint | floatexternalPortNumberExternalPortdoubleExternalPort*float64 required #External listening port.
externalProtocoloptionalLoadBalancingProtocolexternal_protocoloptionalLoadBalancingProtocolexternalProtocoloptionalLoadBalancingProtocolExternalProtocoloptionalLoadBalancingProtocolExternalProtocoloptionalLoadBalancingProtocol #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.
internalPortoptionalnumberinternal_portoptionalint | floatinternalPortoptionalNumberInternalPortoptionaldoubleInternalPortoptional*float64 = externalPort #Instance listening port.
Same as the externalPort if not specified.
internalProtocoloptionalLoadBalancingProtocolinternal_protocoloptionalLoadBalancingProtocolinternalProtocoloptionalLoadBalancingProtocolInternalProtocoloptionalLoadBalancingProtocolInternalProtocoloptionalLoadBalancingProtocol #What public protocol to use for load balancing.
notes
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'.
policyNamesoptionalstring[]policy_namesoptionaltyping.List[str]policyNamesoptionalList<String>PolicyNamesoptionalstring[]PolicyNamesoptional*[]*string #SSL policy names.
sslCertificateArnoptionalstringssl_certificate_arnoptionalstrsslCertificateArnoptionalStringSslCertificateArnoptionalstringSslCertificateArnoptional*string = none #the ARN of the SSL certificate.