import * as aws from "@pulumi/aws" ; import * as pulumi from "@pulumi/pulumi" ; import * as mod from "." ; import * as x from ".." ; import * as utils from "../utils" ; export abstract class TargetGroup extends pulumi . ComponentResource implements x . ecs . ContainerPortMappingProvider , x . ecs . ContainerLoadBalancerProvider , x . lb . ListenerDefaultAction , x . lb . ListenerActions { public readonly loadBalancer : mod . LoadBalancer ; public readonly targetGroup : aws . lb . TargetGroup ; public readonly vpc : x . ec2 . Vpc ; public readonly listeners : x . lb . Listener [ ] = [ ] ; constructor ( type , name , loadBalancer , args , opts ) { super ( type , name , { } , { parent : loadBalancer , ... pulumi . mergeOptions ( opts , { aliases : [ { parent : opts . parent } ] } ) , } ) ; this . vpc = args . vpc ; this . targetGroup = args . targetGroup || new aws . lb . TargetGroup ( name , { ... args , vpcId : this . vpc . id , protocol : utils . ifUndefined ( args . protocol , "HTTP" ) , deregistrationDelay : utils . ifUndefined ( args . deregistrationDelay , 300 ) , targetType : utils . ifUndefined ( args . targetType , "ip" ) , tags : utils . mergeTags ( args . tags , { Name : name } ) , } , { parent : this , aliases : [ { name : args . name || utils . sha1hash ( name ) } ] , } ) ; this . loadBalancer = loadBalancer ; } private dependencies ( ) { return pulumi . output ( this . listeners . map ( r => r . listener . urn ) ) ; } internal public async getListenersAsync ( ) { return this . listeners ; } public containerPortMapping ( ) { return pulumi . output ( [ this . targetGroup . port , this . dependencies ( ) ] ) . apply ( ( [ port ] ) => ( { containerPort : + port ! , } ) ) ; } public containerLoadBalancer ( ) { return this . dependencies ( ) . apply ( _ => ( { containerPort : this . targetGroup . port . apply ( p => p ! ) , targetGroupArn : this . targetGroup . arn , } ) ) ; } public listenerDefaultAction ( ) { return this . dependencies ( ) . apply ( _ => ( { targetGroupArn : this . targetGroup . arn , type : "forward" , } ) ) ; } public actions ( ) { return [ this . listenerDefaultAction ( ) ] ; } /** Do not call directly.  Intended for use by [Listener] and [ListenerRule] */ public registerListener ( listener ) { this . listeners . push ( listener ) ; } /**
     * Attaches a target to this target group.  See
     * [Register-Targets](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-register-targets.html)
     * for more details.
     */ public attachTarget ( name , args , opts = { } ) { return new mod . TargetGroupAttachment ( name , this , args , opts ) ; } } /**
 * A Health Check block.
 *
 * The Health Check parameters you can set vary by the protocol of the Target Group. Many
 * parameters cannot be set to custom values for network load balancers at this time. See
 * http://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_CreateTargetGroup.html
 * for a complete reference. Keep in mind, that health checks produce actual requests to the
 * backend. The underlying function is invoked when target_type is set to lambda.
 */ export interface TargetGroupHealthCheck { /**
     * The approximate amount of time, in seconds, between health checks of an individual
     * target. Minimum value 5 seconds, Maximum value 300 seconds. For lambda target groups, it
     * needs to be greater as the [timeout] of the underlying [lambda]. Default 30 seconds.
     */ interval ? : pulumi . Input < number > ; /**
     * The HTTP codes to use when checking for a successful response from a target. You can specify
     * multiple values (for example, "200,202") or a range of values (for example, "200-299").
     * Applies to Application Load Balancers only (HTTP/HTTPS), not Network Load Balancers (TCP)
     */ matcher ? : pulumi . Input < string > ; /**
     * (Required for HTTP/HTTPS ALB) The destination for the health check request. Applies to
     * Application Load Balancers only (HTTP/HTTPS), not Network Load Balancers (TCP).
     */ path ? : pulumi . Input < string > ; /**
     * The port to use to connect with the target.
     */ port ? : pulumi . Input < string > ; /**
     * The protocol to use to connect with the target. Defaults to HTTP. Not applicable when
     * target_type is [lambda].
     */ protocol ? : pulumi . Input < string > ; /**
     * The amount of time, in seconds, during which no response means a failed health check. For
     * Application Load Balancers, the range is 2 to 60 seconds and the default is 5 seconds.
     * For Network Load Balancers, you cannot set a custom value, and the default is 10 seconds
     * for TCP and HTTPS health checks and 6 seconds for HTTP health checks.
     */ timeout ? : pulumi . Input < number > ; /**
    * The number of consecutive health checks successes required before considering an
    * unhealthy target healthy. Defaults to 3.
    */ healthyThreshold ? : pulumi . Input < number > ; /**
     * The number of consecutive health check failures required before considering the target
     * unhealthy. For Network Load Balancers, this value must be the same as the
     * healthy_threshold. Defaults to 3.
     */ unhealthyThreshold ? : pulumi . Input < number > ; } export interface TargetGroupArgs { /**
     * An existing aws.lb.TargetGroup to use for this awsx.lb.TargetGroup.
     * If not provided, one will be created.
     */ targetGroup ? : aws . lb . TargetGroup ; /**
     * The vpc for this target group.
     */ vpc : x . ec2 . Vpc ; deprecated name ? : string ; /**
     * The amount time for Elastic Load Balancing to wait before changing the state of a
     * deregistering target from draining to unused. The range is 0-3600 seconds. The default value
     * is 300 seconds.
     */ deregistrationDelay ? : pulumi . Input < number > ; /**
     * Health check parameters for this target group.
     */ healthCheck ? : pulumi . Input < TargetGroupHealthCheck > ; /**
     * The port to use to connect with the target. Valid values are either ports 1-65536, or
     * `traffic-port`. Defaults to `traffic-port`.
     */ port : pulumi . Input < number > | undefined ; /**
     * The protocol to use to connect with the target.
     */ protocol : pulumi . Input < "HTTP" | "HTTPS" | "TCP" | "TLS" | "GENEVE" | "UDP" | "TCP_UDP" > | undefined ; /**
     * Boolean to enable / disable support for proxy protocol v2 on Network Load Balancers. See
     * [doc](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html#proxy-protocol)
     * for more information.
     */ proxyProtocolV2 ? : pulumi . Input < boolean > ; /**
     * The amount time for targets to warm up before the load balancer sends them a full share of
     * requests. The range is 30-900 seconds or 0 to disable. The default value is 0 seconds.
     */ slowStart ? : pulumi . Input < number > ; /**
     * A Stickiness block. Stickiness blocks are documented below. `stickiness` is only valid if
     * used with Load Balancers of type `Application`
     */ stickiness ? : aws . lb . TargetGroupArgs [ "stickiness" ] ; /**
     * A mapping of tags to assign to the resource.
     */ tags ? : pulumi . Input < aws . Tags > ; /**
     * The type of target that you must specify when registering targets with this target group. The
     * possible values are `instance` (targets are specified by instance ID) or `ip` (targets are
     * specified by IP address) or `lambda` (targets are specified by lambda arn). The default is
     * `ip`. Note that you can't specify targets for a target group using both instance IDs
     * and IP addresses. If the target type is `ip`, specify IP addresses from the subnets of the
     * virtual private cloud (VPC) for the target group, the RFC 1918 range (10.0.0.0/8,
     * 172.16.0.0/12, and 192.168.0.0/16), and the RFC 6598 range (100.64.0.0/10). You can't specify
     * publicly routable IP addresses.
     */ targetType ? : pulumi . Input < TargetType > ; } /**
 * The type of target that you must specify when registering targets with a target group. The
 * possible values are `instance` (targets are specified by instance ID) or `ip` (targets are
 * specified by IP address) or `lambda` (targets are specified by lambda arn). The default is `ip`.
 * Note that you can't specify targets for a target group using both instance IDs and IP addresses.
 * If the target type is `ip`, specify IP addresses from the subnets of the virtual private cloud
 * (VPC) for the target group, the RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16),
 * and the RFC 6598 range (100.64.0.0/10). You can't specify publicly routable IP addresses.
 *
 * Network Load Balancers do not support the lambda target type, only Application Load Balancers
 * support the lambda target type. For more information, see
 * [Lambda-Functions-as-Targets](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#register-lambda-function)
 * in the User Guide for Application Load Balancers.
 */ export type TargetType = "instance" | "ip" | "lambda" ;