Construct which creates a Target Group.

This construct should be used in conjunction with [[GuApplicationLoadBalancer]] and [[GuApplicationListener]] to route traffic to your application. For more details on these three components, see the AWS documentation.

By default, Target Groups created via this construct will perform a healthcheck against /healthcheck on your application's traffic port (as specified via the port prop). All healthcheck defaults can be overridden via the healthcheck prop.

For example, to use /test for the healthcheck path use:

new GuApplicationTargetGroup(stack, "TargetGroup", {
// other props
healthCheck: {
path: "/test",
},
});

This resource is stateful.

Hierarchy

  • Mixin<typeof ApplicationTargetGroup, this> & ApplicationTargetGroup<this>
    • GuApplicationTargetGroup

Constructors

Properties

defaultPort: number

Default port configured for members of this target group

healthCheck: HealthCheck

Health check for the members of this target group

idWithApp: string

The ID of the construct with the App suffix. This should be used in place of id when trying to reference the construct.

loadBalancerArns: string

A token representing a list of ARNs of the load balancers that route traffic to this target group

loadBalancerAttachedDependencies: DependencyGroup

Configurable dependable with all resources that lead to load balancer attachment

node: Node

The tree node.

targetGroupArn: string

The ARN of the target group

targetGroupFullName: string

The full name of the target group

targetGroupLoadBalancerArns: string[]

ARNs of load balancers load balancing to this TargetGroup

targetGroupName: string

The name of the target group

targetType?: TargetType

The types of the directly registered members of this target group

DefaultHealthCheck: HealthCheck = ...

Accessors

  • get firstLoadBalancerFullName(): string
  • Full name of first load balancer

    Returns string

  • get loadBalancerAttached(): IDependable
  • List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer

    Returns IDependable

  • get metrics(): IApplicationTargetGroupMetrics
  • All metrics available for this target group.

    Returns IApplicationTargetGroupMetrics

Methods

  • Register the given load balancing target as part of this group

    Parameters

    • props: LoadBalancerTargetProps

    Returns void

  • Add a load balancing target to this target group

    Parameters

    • ...targets: IApplicationLoadBalancerTarget[]

    Returns void

  • Set/replace the target group's health check

    Parameters

    • healthCheck: HealthCheck

    Returns void

  • 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).

    Parameters

    • duration: Duration
    • OptionalcookieName: string

    Returns void

  • Return the given named metric for this Application Load Balancer Target Group

    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.

    Parameters

    • metricName: string
    • Optionalprops: MetricOptions

    Returns Metric

    Average over 5 minutes
    
  • The number of healthy hosts in the target group

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Average over 5 minutes
    

    Use ApplicationTargetGroup.metrics.healthyHostCount instead

  • The number of HTTP 2xx/3xx/4xx/5xx response codes generated by all targets in this target group.

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

    Parameters

    • code: HttpCodeTarget
    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.httpCodeTarget instead

  • The number of IPv6 requests received by the target group

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.ipv6RequestCount instead

  • The number of requests processed over IPv4 and IPv6.

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

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.requestCount instead

  • The average number of requests received by each target in a target group.

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

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.requestCountPerTarget instead

  • The number of connections that were not successfully established between the load balancer and target.

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.targetConnectionErrorCount instead

  • The time elapsed, in seconds, after the request leaves the load balancer until a response from the target is received.

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Average over 5 minutes
    

    Use ApplicationTargetGroup.metrics.targetResponseTime instead

  • The number of TLS connections initiated by the load balancer that did not establish a session with the target.

    Possible causes include a mismatch of ciphers or protocols.

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Sum over 5 minutes
    

    Use ApplicationTargetGroup.metrics.tlsNegotiationErrorCount instead

  • The number of unhealthy hosts in the target group

    Parameters

    • Optionalprops: MetricOptions

    Returns Metric

    Average over 5 minutes
    

    Use ApplicationTargetGroup.metrics.unhealthyHostCount instead

  • Register a connectable as a member of this target group.

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

    Parameters

    • connectable: IConnectable
    • OptionalportRange: Port

    Returns void

  • Register a listener that is load balancing to this target group.

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

    Parameters

    • listener: IApplicationListener
    • OptionalassociatingConstruct: IConstruct

    Returns void

  • Returns a string representation of an object.

    Returns string

  • Returns string[]

  • Returns string[]

  • Import an existing target group

    Parameters

    • scope: Construct
    • id: string
    • attrs: TargetGroupAttributes

    Returns IApplicationTargetGroup

  • Checks if x is a construct.

    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

    • x: any

      Any object

    Returns x is Construct

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