Class NetworkListener
Define a Network Listener.
Inherited Members
Namespace: Amazon.CDK.AWS.ElasticLoadBalancingV2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class NetworkListener : BaseListener, INetworkListener, IListener, IResource
Syntax (vb)
Public Class NetworkListener
Inherits BaseListener
Implements INetworkListener, IListener, IResource
Remarks
Resource: AWS::ElasticLoadBalancingV2::Listener
ExampleMetadata: infused
Examples
Vpc vpc;
AutoScalingGroup asg;
ISecurityGroup sg1;
ISecurityGroup sg2;
// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
var lb = new NetworkLoadBalancer(this, "LB", new NetworkLoadBalancerProps {
Vpc = vpc,
InternetFacing = true,
SecurityGroups = new [] { sg1 }
});
lb.AddSecurityGroup(sg2);
// Add a listener on a particular port.
var listener = lb.AddListener("Listener", new BaseNetworkListenerProps {
Port = 443
});
// Add targets on a particular port.
listener.AddTargets("AppFleet", new AddNetworkTargetsProps {
Port = 443,
Targets = new [] { asg }
});
Synopsis
Constructors
NetworkListener(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
NetworkListener(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
NetworkListener(Construct, String, INetworkListenerProps) |
Properties
LoadBalancer | The load balancer this listener is attached to. |
Methods
AddAction(String, IAddNetworkActionProps) | Perform the given Action on incoming requests. |
AddCertificates(String, IListenerCertificate[]) | Add one or more certificates to this listener. |
AddTargetGroups(String, INetworkTargetGroup[]) | Load balance incoming requests to the given target groups. |
AddTargets(String, IAddNetworkTargetsProps) | Load balance incoming requests to the given load balancing targets. |
FromLookup(Construct, String, INetworkListenerLookupOptions) | Looks up a network listener. |
FromNetworkListenerArn(Construct, String, String) | Import an existing listener. |
Constructors
NetworkListener(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected NetworkListener(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
NetworkListener(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected NetworkListener(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
NetworkListener(Construct, String, INetworkListenerProps)
public NetworkListener(Construct scope, string id, INetworkListenerProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props INetworkListenerProps
Properties
LoadBalancer
The load balancer this listener is attached to.
public virtual INetworkLoadBalancer LoadBalancer { get; }
Property Value
Methods
AddAction(String, IAddNetworkActionProps)
Perform the given Action on incoming requests.
public virtual void AddAction(string id, IAddNetworkActionProps props)
Parameters
- id System.String
- props IAddNetworkActionProps
Remarks
This allows full control of the default Action of the load balancer,
including weighted forwarding. See the NetworkListenerAction
class for
all options.
AddCertificates(String, IListenerCertificate[])
Add one or more certificates to this listener.
public virtual void AddCertificates(string id, IListenerCertificate[] certificates)
Parameters
- id System.String
- certificates IListenerCertificate[]
Remarks
After the first certificate, this creates NetworkListenerCertificates resources since cloudformation requires the certificates array on the listener resource to have a length of 1.
AddTargetGroups(String, INetworkTargetGroup[])
Load balance incoming requests to the given target groups.
public virtual void AddTargetGroups(string id, params INetworkTargetGroup[] targetGroups)
Parameters
- id System.String
- targetGroups INetworkTargetGroup[]
Remarks
All target groups will be load balanced to with equal weight and without
stickiness. For a more complex configuration than that, use addAction()
.
AddTargets(String, IAddNetworkTargetsProps)
Load balance incoming requests to the given load balancing targets.
public virtual NetworkTargetGroup AddTargets(string id, IAddNetworkTargetsProps props)
Parameters
- id System.String
- props IAddNetworkTargetsProps
Returns
The newly created target group
Remarks
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.
FromLookup(Construct, String, INetworkListenerLookupOptions)
Looks up a network listener.
public static INetworkListener FromLookup(Construct scope, string id, INetworkListenerLookupOptions options)
Parameters
- scope Constructs.Construct
- id System.String
- options INetworkListenerLookupOptions
Returns
FromNetworkListenerArn(Construct, String, String)
Import an existing listener.
public static INetworkListener FromNetworkListenerArn(Construct scope, string id, string networkListenerArn)
Parameters
- scope Constructs.Construct
- id System.String
- networkListenerArn System.String
Returns