Skip to content
v2.275.0

ApplicationTargetGroup ​

Define an Application Target Group.

Example ​

ts
declare const alb: elbv2.ApplicationLoadBalancer;
const listener = alb.addListener('Listener', { port: 80 });
const targetGroup = listener.addTargets('Fleet', { port: 80 });

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancer: codedeploy.LoadBalancer.application(targetGroup),
});
python
# alb: elbv2.ApplicationLoadBalancer

listener = alb.add_listener("Listener", port=80)
target_group = listener.add_targets("Fleet", port=80)

deployment_group = codedeploy.ServerDeploymentGroup(self, "DeploymentGroup",
    load_balancer=codedeploy.LoadBalancer.application(target_group)
)
java
ApplicationLoadBalancer alb;

ApplicationListener listener = alb.addListener("Listener", BaseApplicationListenerProps.builder().port(80).build());
ApplicationTargetGroup targetGroup = listener.addTargets("Fleet", AddApplicationTargetsProps.builder().port(80).build());

ServerDeploymentGroup deploymentGroup = ServerDeploymentGroup.Builder.create(this, "DeploymentGroup")
        .loadBalancer(LoadBalancer.application(targetGroup))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
ApplicationLoadBalancer alb;

var listener = alb.AddListener("Listener", new BaseApplicationListenerProps { Port = 80 });
var targetGroup = listener.AddTargets("Fleet", new AddApplicationTargetsProps { Port = 80 });

var deploymentGroup = new ServerDeploymentGroup(this, "DeploymentGroup", new ServerDeploymentGroupProps {
    LoadBalancer = LoadBalancer.Application(targetGroup)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var alb ApplicationLoadBalancer

listener := alb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),
})
targetGroup := listener.AddTargets(jsii.String("Fleet"), &AddApplicationTargetsProps{
	Port: jsii.Number(80),
})

deploymentGroup := codedeploy.NewServerDeploymentGroup(this, jsii.String("DeploymentGroup"), &ServerDeploymentGroupProps{
	LoadBalancer: codedeploy.LoadBalancer_Application(targetGroup),
})

Initializer ​

ts
new ApplicationTargetGroup(scope: Construct, id: string, props?: ApplicationTargetGroupProps)
python
ApplicationTargetGroup(scope: Construct, id: str, props: typing.Optional[ApplicationTargetGroupProps] = None)
java
new ApplicationTargetGroup(Construct scope, String id, ApplicationTargetGroupProps props)
csharp
new ApplicationTargetGroup(Construct scope, string id, ApplicationTargetGroupProps? props = null)
go
NewApplicationTargetGroup(Scope Construct, Id *string, Props ApplicationTargetGroupProps)

Construct Props ​

crossZoneEnabledoptionalbooleancross_zone_enabledoptionalboolcrossZoneEnabledoptionalBooleanCrossZoneEnabledoptionalboolCrossZoneEnabledoptional*bool#
Indicates whether cross zone load balancing is enabled.

Default: use load balancer configuration

deregistrationDelayoptionalDurationderegistration_delayoptionalDurationderegistrationDelayoptionalDurationDeregistrationDelayoptionalDurationDeregistrationDelayoptionalDuration= 300#
The amount of time for Elastic Load Balancing to wait before deregistering a target.

The range is 0-3600 seconds.

enableAnomalyMitigationoptionalbooleanenable_anomaly_mitigationoptionalboolenableAnomalyMitigationoptionalBooleanEnableAnomalyMitigationoptionalboolEnableAnomalyMitigationoptional*bool= false#
Indicates whether anomaly mitigation is enabled.

Only available when loadBalancingAlgorithmType is TargetGroupLoadBalancingAlgorithmType.WEIGHTED_RANDOM

healthCheckoptionalHealthCheckhealth_checkoptionalHealthCheckhealthCheckoptionalHealthCheckHealthCheckoptionalHealthCheckHealthCheckoptionalHealthCheck#
Health check configuration.

Default: The default value for each property in this configuration varies depending on the target.

ipAddressTypeoptionalTargetGroupIpAddressTypeip_address_typeoptionalTargetGroupIpAddressTypeipAddressTypeoptionalTargetGroupIpAddressTypeIpAddressTypeoptionalTargetGroupIpAddressTypeIpAddressTypeoptionalTargetGroupIpAddressType#
The type of IP addresses of the targets registered with the target group.

Default: undefined - ELB defaults to IPv4

loadBalancingAlgorithmTypeoptionalTargetGroupLoadBalancingAlgorithmTypeload_balancing_algorithm_typeoptionalTargetGroupLoadBalancingAlgorithmTypeloadBalancingAlgorithmTypeoptionalTargetGroupLoadBalancingAlgorithmTypeLoadBalancingAlgorithmTypeoptionalTargetGroupLoadBalancingAlgorithmTypeLoadBalancingAlgorithmTypeoptionalTargetGroupLoadBalancingAlgorithmType#
The load balancing algorithm to select targets for routing requests.

Default: TargetGroupLoadBalancingAlgorithmType.ROUND_ROBIN

multiValueHeadersEnabledoptionalbooleanmulti_value_headers_enabledoptionalboolmultiValueHeadersEnabledoptionalBooleanMultiValueHeadersEnabledoptionalboolMultiValueHeadersEnabledoptional*bool= false#
Indicates whether the target group supports multi-value headers.

If the value is true, the request and response headers exchanged between the load balancer and the Lambda function include arrays of values or strings.

Only applicable for Lambda targets.

portoptionalnumberportoptionalint | floatportoptionalNumberPortoptionaldoublePortoptional*float64#
The port on which the target receives traffic.

Default: Determined from protocol if known

This is not applicable for Lambda targets.

protocoloptionalApplicationProtocolprotocoloptionalApplicationProtocolprotocoloptionalApplicationProtocolProtocoloptionalApplicationProtocolProtocoloptionalApplicationProtocol#
The protocol used for communication with the target.

Default: Determined from port if known

This is not applicable for Lambda targets.

protocolVersionoptionalApplicationProtocolVersionprotocol_versionoptionalApplicationProtocolVersionprotocolVersionoptionalApplicationProtocolVersionProtocolVersionoptionalApplicationProtocolVersionProtocolVersionoptionalApplicationProtocolVersion= ApplicationProtocolVersion.HTTP1#
The protocol version to use.
slowStartoptionalDurationslow_startoptionalDurationslowStartoptionalDurationSlowStartoptionalDurationSlowStartoptionalDuration= 0#
The time period during which the load balancer sends a newly registered target a linearly increasing share of the traffic to the target group.

The range is 30-900 seconds (15 minutes).

stickinessCookieDurationoptionalDurationstickiness_cookie_durationoptionalDurationstickinessCookieDurationoptionalDurationStickinessCookieDurationoptionalDurationStickinessCookieDurationoptionalDuration#
The stickiness cookie expiration period.

Default: Stickiness is disabled

Setting this value enables load balancer stickiness.

After this period, the cookie is considered stale. The minimum value is 1 second and the maximum value is 7 days (604800 seconds).

stickinessCookieNameoptionalstringstickiness_cookie_nameoptionalstrstickinessCookieNameoptionalStringStickinessCookieNameoptionalstringStickinessCookieNameoptional*string#
The name of an application-based stickiness cookie.

Default: If stickinessCookieDuration is set, a load-balancer generated cookie is used. Otherwise, no stickiness is defined.

notes

Names that start with the following prefixes are not allowed: AWSALB, AWSALBAPP, and AWSALBTG; they're reserved for use by the load balancer.

Note: stickinessCookieName parameter depends on the presence of stickinessCookieDuration parameter. If stickinessCookieDuration is not set, stickinessCookieName will be omitted.

targetGroupHealthoptionalTargetGroupHealthtarget_group_healthoptionalTargetGroupHealthtargetGroupHealthoptionalTargetGroupHealthTargetGroupHealthoptionalTargetGroupHealthTargetGroupHealthoptionalTargetGroupHealth#
Configuring target group health.

Default: use default configuration

targetGroupNameoptionalstringtarget_group_nameoptionalstrtargetGroupNameoptionalStringTargetGroupNameoptionalstringTargetGroupNameoptional*string#
The name of the target group.

Default: Automatically generated.

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.

targetsoptionalIApplicationLoadBalancerTarget[]targetsoptionaltyping.List[IApplicationLoadBalancerTarget]targetsoptionalList<IApplicationLoadBalancerTarget>TargetsoptionalIApplicationLoadBalancerTarget[]Targetsoptional*[]IApplicationLoadBalancerTarget#
The targets to add to this target group.

Default: No targets.

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.

targetTypeoptionalTargetTypetarget_typeoptionalTargetTypetargetTypeoptionalTargetTypeTargetTypeoptionalTargetTypeTargetTypeoptionalTargetType#
The type of targets registered to this TargetGroup, either IP or Instance.

Default: Determined automatically.

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.

vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc= undefined#
The virtual private cloud (VPC).

only if TargetType is Ip or InstanceId

Properties ​

firstLoadBalancerFullNamestringfirst_load_balancer_full_namestrfirstLoadBalancerFullNameStringFirstLoadBalancerFullNamestringFirstLoadBalancerFullName*string#
Full name of first load balancer.
healthCheckHealthCheckhealth_checkHealthCheckhealthCheckHealthCheckHealthCheckHealthCheckHealthCheckHealthCheck#
Health check for the members of this target group.
loadBalancerArnsstringload_balancer_arnsstrloadBalancerArnsStringLoadBalancerArnsstringLoadBalancerArns*string#
A token representing a list of ARNs of the load balancers that route traffic to this target group.
loadBalancerAttachedIDependableload_balancer_attachedIDependableloadBalancerAttachedIDependableLoadBalancerAttachedIDependableLoadBalancerAttachedIDependable#
List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
targetGroupArnstringtarget_group_arnstrtargetGroupArnStringTargetGroupArnstringTargetGroupArn*string#
The ARN of the target group.
targetGroupFullNamestringtarget_group_full_namestrtargetGroupFullNameStringTargetGroupFullNamestringTargetGroupFullName*string#
The full name of the target group.
targetGroupLoadBalancerArnsstring[]target_group_load_balancer_arnstyping.List[str]targetGroupLoadBalancerArnsList<String>TargetGroupLoadBalancerArnsstring[]TargetGroupLoadBalancerArns*[]*string#
ARNs of load balancers load balancing to this TargetGroup.
targetGroupNamestringtarget_group_namestrtargetGroupNameStringTargetGroupNamestringTargetGroupName*string#
The name of the target group.
targetGroupRefTargetGroupReferencetarget_group_refTargetGroupReferencetargetGroupRefTargetGroupReferenceTargetGroupRefTargetGroupReferenceTargetGroupRefTargetGroupReference#
A reference to this target group.

Methods ​

addTarget(...targets: IApplicationLoadBalancerTarget[]): voiddef add_target(self, targets: IApplicationLoadBalancerTarget) -> Nonepublic void addTarget(IApplicationLoadBalancerTarget targets)public void AddTarget(IApplicationLoadBalancerTarget targets)func AddTarget(Targets IApplicationLoadBalancerTarget)#
Add a load balancing target to this target group.
configureHealthCheck(healthCheck: HealthCheck): voiddef configure_health_check(self, health_check: HealthCheck) -> Nonepublic void configureHealthCheck(HealthCheck healthCheck)public void ConfigureHealthCheck(HealthCheck healthCheck)func ConfigureHealthCheck(HealthCheck HealthCheck)#
Set/replace the target group's health check.
enableCookieStickiness(duration: Duration, cookieName?: string): voiddef enable_cookie_stickiness(self, duration: Duration, cookie_name: typing.Optional[str] = None) -> Nonepublic void enableCookieStickiness(Duration duration, String cookieName)public void EnableCookieStickiness(Duration duration, string? cookieName = null)func EnableCookieStickiness(Duration Duration, CookieName *string)#
Enable sticky routing via a cookie to members of this target group.

Note: If the cookieName parameter is set, application-based stickiness will be applied, otherwise it defaults to duration-based stickiness attributes (lb_cookie).

fromTargetGroupAttributes(scope: Construct, id: string, attrs: TargetGroupAttributes): IApplicationTargetGroup@staticmethod def from_target_group_attributes(scope: Construct, id: str, attrs: TargetGroupAttributes) -> IApplicationTargetGrouppublic static IApplicationTargetGroup fromTargetGroupAttributes(Construct scope, String id, TargetGroupAttributes attrs)public static IApplicationTargetGroup FromTargetGroupAttributes(Construct scope, string id, TargetGroupAttributes attrs)func FromTargetGroupAttributes(Scope Construct, Id *string, Attrs TargetGroupAttributes) IApplicationTargetGroupstatic#
Import an existing target group.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#
Return the given named metric for this Application Load Balancer Target Group.
notes

Returns the metric for this target group from the point of view of the first load balancer load balancing to it. If you have multiple load balancers load sending traffic to the same target group, you will have to override the dimensions on this metric.

metricHealthyHostCount(props?: MetricOptions): Metricdef metric_healthy_host_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricHealthyHostCount(MetricOptions props)public Metric MetricHealthyHostCount(MetricOptions? props = null)func MetricHealthyHostCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.healthyHostCount`` instead
metricHttpCodeTarget(code: HttpCodeTarget, props?: MetricOptions): Metricdef metric_http_code_target(self, code: HttpCodeTarget, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricHttpCodeTarget(HttpCodeTarget code, MetricOptions props)public Metric MetricHttpCodeTarget(HttpCodeTarget code, MetricOptions? props = null)func MetricHttpCodeTarget(Code HttpCodeTarget, Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.httpCodeTarget`` instead

This does not include any response codes generated by the load balancer.

metricIpv6RequestCount(props?: MetricOptions): Metricdef metric_ipv6_request_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricIpv6RequestCount(MetricOptions props)public Metric MetricIpv6RequestCount(MetricOptions? props = null)func MetricIpv6RequestCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.ipv6RequestCount`` instead
metricRequestCount(props?: MetricOptions): Metricdef metric_request_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricRequestCount(MetricOptions props)public Metric MetricRequestCount(MetricOptions? props = null)func MetricRequestCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.requestCount`` instead

This count includes only the requests with a response generated by a target of the load balancer.

metricRequestCountPerTarget(props?: MetricOptions): Metricdef metric_request_count_per_target(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricRequestCountPerTarget(MetricOptions props)public Metric MetricRequestCountPerTarget(MetricOptions? props = null)func MetricRequestCountPerTarget(Props MetricOptions) Metricdeprecated#
Use `ApplicationTargetGroup.metrics.requestCountPerTarget` instead

The only valid statistic is Sum. Note that this represents the average not the sum.

metricTargetConnectionErrorCount(props?: MetricOptions): Metricdef metric_target_connection_error_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTargetConnectionErrorCount(MetricOptions props)public Metric MetricTargetConnectionErrorCount(MetricOptions? props = null)func MetricTargetConnectionErrorCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.targetConnectionErrorCount`` instead
metricTargetResponseTime(props?: MetricOptions): Metricdef metric_target_response_time(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTargetResponseTime(MetricOptions props)public Metric MetricTargetResponseTime(MetricOptions? props = null)func MetricTargetResponseTime(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.targetResponseTime`` instead
metricTargetTLSNegotiationErrorCount(props?: MetricOptions): Metricdef metric_target_tls_negotiation_error_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTargetTLSNegotiationErrorCount(MetricOptions props)public Metric MetricTargetTLSNegotiationErrorCount(MetricOptions? props = null)func MetricTargetTLSNegotiationErrorCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.tlsNegotiationErrorCount`` instead

Possible causes include a mismatch of ciphers or protocols.

metricUnhealthyHostCount(props?: MetricOptions): Metricdef metric_unhealthy_host_count(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricUnhealthyHostCount(MetricOptions props)public Metric MetricUnhealthyHostCount(MetricOptions? props = null)func MetricUnhealthyHostCount(Props MetricOptions) Metricdeprecated#
Use ``ApplicationTargetGroup.metrics.unhealthyHostCount`` instead
registerConnectable(connectable: IConnectable, portRange?: Port): voiddef register_connectable(self, connectable: IConnectable, port_range: typing.Optional[Port] = None) -> Nonepublic void registerConnectable(IConnectable connectable, Port portRange)public void RegisterConnectable(IConnectable connectable, Port? portRange = null)func RegisterConnectable(Connectable IConnectable, PortRange Port)#
Register a connectable as a member of this target group.

Don't call this directly. It will be called by load balancing targets.

registerListener(listener: IApplicationListener, associatingConstruct?: IConstruct): voiddef register_listener(self, listener: IApplicationListener, associating_construct: typing.Optional[IConstruct] = None) -> Nonepublic void registerListener(IApplicationListener listener, IConstruct associatingConstruct)public void RegisterListener(IApplicationListener listener, IConstruct? associatingConstruct = null)func RegisterListener(Listener IApplicationListener, AssociatingConstruct IConstruct)#
Register a listener that is load balancing to this target group.

Don't call this directly. It will be called by listeners.

setAttribute(key: string, value?: string): voiddef set_attribute(self, key: str, value: typing.Optional[str] = None) -> Nonepublic void setAttribute(String key, String value)public void SetAttribute(string key, string? value = null)func SetAttribute(Key *string, Value *string)#
Set a non-standard attribute on the target group.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining