in src/constructs/loadbalancing/alb/application-target-group.ts [46:68]
constructor(scope: GuStack, id: string, props: GuApplicationTargetGroupProps) {
const mergedProps: ApplicationTargetGroupProps = {
protocol: ApplicationProtocol.HTTP, // We terminate HTTPS at the load balancer level, so load balancer to ASG/EC2 traffic can be over HTTP
deregistrationDelay: Duration.seconds(30),
...props,
healthCheck: { ...GuApplicationTargetGroup.DefaultHealthCheck, ...props.healthCheck },
};
super(scope, id, mergedProps);
const interval = mergedProps.healthCheck?.interval ?? GuApplicationTargetGroup.defaultHealthcheckInterval;
const timeout = mergedProps.healthCheck?.timeout ?? GuApplicationTargetGroup.defaultHealthcheckTimeout;
/*
The healthcheck `timeout` must be lower than `interval`
See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-health-check.html#cfn-elb-healthcheck-timeout
*/
if (timeout.toSeconds() >= interval.toSeconds()) {
const message = `Illegal healthcheck configuration: timeout (${timeout.toSeconds()}) must be lower than interval (${interval.toSeconds()})`;
Annotations.of(this).addError(message); // adds a useful message to the console to aid debugging
throw new Error(message);
}
}