Class Listener
The construct for the Listener.
Inherited Members
Namespace: Amazon.CDK.AWS.GlobalAccelerator
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Listener : Resource, IListener, IResource, IConstruct, IDependable
Syntax (vb)
Public Class Listener Inherits Resource Implements IListener, IResource, IConstruct, IDependable
Remarks
ExampleMetadata: infused
Examples
// Create an Accelerator
var accelerator = new Accelerator(this, "Accelerator");
// Create a Listener
var listener = accelerator.AddListener("Listener", new ListenerOptions {
PortRanges = new [] { new PortRange { FromPort = 80 }, new PortRange { FromPort = 443 } }
});
// Import the Load Balancers
var nlb1 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB1", new NetworkLoadBalancerAttributes {
LoadBalancerArn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
});
var nlb2 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB2", new NetworkLoadBalancerAttributes {
LoadBalancerArn = "arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"
});
// Add one EndpointGroup for each Region we are targeting
listener.AddEndpointGroup("Group1", new EndpointGroupOptions {
Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb1) }
});
listener.AddEndpointGroup("Group2", new EndpointGroupOptions {
// Imported load balancers automatically calculate their Region from the ARN.
// If you are load balancing to other resources, you must also pass a `region`
// parameter here.
Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb2) }
});
Synopsis
Constructors
Listener(Construct, string, IListenerProps) | The construct for the Listener. |
Properties
ListenerArn | The ARN of the listener. |
ListenerName | The name of the listener. |
PROPERTY_INJECTION_ID | Uniquely identifies this class. |
Methods
AddEndpointGroup(string, IEndpointGroupOptions?) | Add a new endpoint group to this listener. |
FromListenerArn(Construct, string, string) | import from ARN. |
Constructors
Listener(Construct, string, IListenerProps)
The construct for the Listener.
public Listener(Construct scope, string id, IListenerProps props)
Parameters
- scope Construct
- id string
- props IListenerProps
Remarks
ExampleMetadata: infused
Examples
// Create an Accelerator
var accelerator = new Accelerator(this, "Accelerator");
// Create a Listener
var listener = accelerator.AddListener("Listener", new ListenerOptions {
PortRanges = new [] { new PortRange { FromPort = 80 }, new PortRange { FromPort = 443 } }
});
// Import the Load Balancers
var nlb1 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB1", new NetworkLoadBalancerAttributes {
LoadBalancerArn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
});
var nlb2 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB2", new NetworkLoadBalancerAttributes {
LoadBalancerArn = "arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"
});
// Add one EndpointGroup for each Region we are targeting
listener.AddEndpointGroup("Group1", new EndpointGroupOptions {
Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb1) }
});
listener.AddEndpointGroup("Group2", new EndpointGroupOptions {
// Imported load balancers automatically calculate their Region from the ARN.
// If you are load balancing to other resources, you must also pass a `region`
// parameter here.
Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb2) }
});
Properties
ListenerArn
The ARN of the listener.
public virtual string ListenerArn { get; }
Property Value
Remarks
ExampleMetadata: infused
ListenerName
The name of the listener.
public virtual string ListenerName { get; }
Property Value
Remarks
Attribute: true
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
ExampleMetadata: infused
Methods
AddEndpointGroup(string, IEndpointGroupOptions?)
Add a new endpoint group to this listener.
public virtual EndpointGroup AddEndpointGroup(string id, IEndpointGroupOptions? options = null)
Parameters
- id string
- options IEndpointGroupOptions
Returns
Remarks
ExampleMetadata: infused
FromListenerArn(Construct, string, string)
import from ARN.
public static IListener FromListenerArn(Construct scope, string id, string listenerArn)
Parameters
Returns
Remarks
ExampleMetadata: infused
Implements
Constructs.IConstruct
Constructs.IDependable