class NetworkTargetGroup (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ElasticLoadBalancingV2.NetworkTargetGroup |
Java | software.amazon.awscdk.services.elasticloadbalancingv2.NetworkTargetGroup |
Python | aws_cdk.aws_elasticloadbalancingv2.NetworkTargetGroup |
TypeScript (source) | @aws-cdk/aws-elasticloadbalancingv2 » NetworkTargetGroup |
Implements
IConstruct
, IConstruct
, IDependable
, ITarget
, INetwork
Define a Network Target Group.
Example
declare const listener: elbv2.NetworkListener;
declare const asg1: autoscaling.AutoScalingGroup;
declare const asg2: autoscaling.AutoScalingGroup;
const group = listener.addTargets('AppFleet', {
port: 443,
targets: [asg1],
});
group.addTarget(asg2);
Initializer
new NetworkTargetGroup(scope: Construct, id: string, props: NetworkTargetGroupProps)
Parameters
- scope
Construct
- id
string
- props
Network
Target Group Props
Construct Props
Name | Type | Description |
---|---|---|
port | number | The port on which the listener listens for requests. |
deregistration | Duration | The amount of time for Elastic Load Balancing to wait before deregistering a target. |
health | Health | Health check configuration. |
preserve | boolean | Indicates whether client IP preservation is enabled. |
protocol? | Protocol | Protocol for target group, expects TCP, TLS, UDP, or TCP_UDP. |
proxy | boolean | Indicates whether Proxy Protocol version 2 is enabled. |
target | string | The name of the target group. |
target | Target | The type of targets registered to this TargetGroup, either IP or Instance. |
targets? | INetwork [] | The targets to add to this target group. |
vpc? | IVpc | The virtual private cloud (VPC). |
port
Type:
number
The port on which the listener listens for requests.
deregistrationDelay?
Type:
Duration
(optional, default: 300)
The amount of time for Elastic Load Balancing to wait before deregistering a target.
The range is 0-3600 seconds.
healthCheck?
Type:
Health
(optional, default: The default value for each property in this configuration varies depending on the target.)
Health check configuration.
preserveClientIp?
Type:
boolean
(optional, default: false if the target group type is IP address and the
target group protocol is TCP or TLS. Otherwise, true.)
Indicates whether client IP preservation is enabled.
protocol?
Type:
Protocol
(optional, default: TCP)
Protocol for target group, expects TCP, TLS, UDP, or TCP_UDP.
proxyProtocolV2?
Type:
boolean
(optional, default: false)
Indicates whether Proxy Protocol version 2 is enabled.
targetGroupName?
Type:
string
(optional, default: Automatically generated.)
The name of the target group.
This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.
targetType?
Type:
Target
(optional, default: Determined automatically.)
The type of targets registered to this TargetGroup, either IP or Instance.
All targets registered into the group must be of this type. If you register targets to the TargetGroup in the CDK app, the TargetType is determined automatically.
targets?
Type:
INetwork
[]
(optional, default: No targets.)
The targets to add to this target group.
Can be Instance
, IPAddress
, or any self-registering load balancing
target. If you use either Instance
or IPAddress
as targets, all
target must be of the same type.
vpc?
Type:
IVpc
(optional, default: undefined)
The virtual private cloud (VPC).
only if TargetType
is Ip
or InstanceId
Properties
Name | Type | Description |
---|---|---|
first | string | Full name of first load balancer. |
health | Health | |
load | string | A token representing a list of ARNs of the load balancers that route traffic to this target group. |
load | IDependable | List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer. |
node | Construct | The construct tree node associated with this construct. |
target | string | The ARN of the target group. |
target | string | The full name of the target group. |
target | string[] | ARNs of load balancers load balancing to this TargetGroup. |
target | string | The name of the target group. |
firstLoadBalancerFullName
Type:
string
Full name of first load balancer.
healthCheck
Type:
Health
loadBalancerArns
Type:
string
A token representing a list of ARNs of the load balancers that route traffic to this target group.
loadBalancerAttached
Type:
IDependable
List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.
node
Type:
Construct
The construct tree node associated with this construct.
targetGroupArn
Type:
string
The ARN of the target group.
targetGroupFullName
Type:
string
The full name of the target group.
targetGroupLoadBalancerArns
Type:
string[]
ARNs of load balancers load balancing to this TargetGroup.
targetGroupName
Type:
string
The name of the target group.
Methods
Name | Description |
---|---|
add | Add a load balancing target to this target group. |
configure | Set/replace the target group's health check. |
metric | The number of targets that are considered healthy. |
metric | The number of targets that are considered unhealthy. |
register | Register a listener that is load balancing to this target group. |
set | Set a non-standard attribute on the target group. |
to | Returns a string representation of this construct. |
protected validate() | Validate the current construct. |
static from | Import an existing target group. |
static import(scope, id, props) | Import an existing listener. |
Target(...targets)
addpublic addTarget(...targets: INetworkLoadBalancerTarget[]): void
Parameters
- targets
INetwork
Load Balancer Target
Add a load balancing target to this target group.
HealthCheck(healthCheck)
configurepublic configureHealthCheck(healthCheck: HealthCheck): void
Parameters
- healthCheck
Health
Check
Set/replace the target group's health check.
HealthyHostCount(props?)
metricpublic metricHealthyHostCount(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The number of targets that are considered healthy.
UnHealthyHostCount(props?)
metricpublic metricUnHealthyHostCount(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The number of targets that are considered unhealthy.
Listener(listener)
registerpublic registerListener(listener: INetworkListener): void
Parameters
- listener
INetwork
Listener
Register a listener that is load balancing to this target group.
Don't call this directly. It will be called by listeners.
Attribute(key, value?)
setpublic setAttribute(key: string, value?: string): void
Parameters
- key
string
- value
string
Set a non-standard attribute on the target group.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
protected validate()
protected validate(): string[]
Returns
string[]
Validate the current construct.
This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.
TargetGroupAttributes(scope, id, attrs)
static frompublic static fromTargetGroupAttributes(scope: Construct, id: string, attrs: TargetGroupAttributes): INetworkTargetGroup
Parameters
- scope
Construct
- id
string
- attrs
Target
Group Attributes
Returns
Import an existing target group.
static import(scope, id, props)
public static import(scope: Construct, id: string, props: TargetGroupImportProps): INetworkTargetGroup
⚠️ Deprecated: Use fromTargetGroupAttributes
instead
Parameters
- scope
Construct
- id
string
- props
Target
Group Import Props
Returns
Import an existing listener.