terraform: use HTTPS health check for AWS

This commit is contained in:
Leonard Cohnen 2022-11-02 11:46:52 +01:00 committed by 3u13r
parent 7e385c4c86
commit be2b38f2ac
3 changed files with 71 additions and 40 deletions

View File

@ -125,6 +125,14 @@ resource "aws_security_group" "security_group" {
description = "konnectivity"
}
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [aws_vpc.vpc.cidr_block]
description = "allow all internal"
}
dynamic "ingress" {
for_each = var.debug ? [1] : []
content {
@ -150,6 +158,7 @@ module "load_balancer_target_bootstrapper" {
lb_arn = aws_lb.front_end.arn
port = local.ports_bootstrapper
tags = local.tags
healthcheck_protocol = "TCP"
}
module "load_balancer_target_kubernetes" {
@ -159,6 +168,8 @@ module "load_balancer_target_kubernetes" {
lb_arn = aws_lb.front_end.arn
port = local.ports_kubernetes
tags = local.tags
healthcheck_protocol = "HTTPS"
healthcheck_path = "/readyz"
}
module "load_balancer_target_verify" {
@ -168,6 +179,7 @@ module "load_balancer_target_verify" {
lb_arn = aws_lb.front_end.arn
port = local.ports_verify
tags = local.tags
healthcheck_protocol = "TCP"
}
module "load_balancer_target_debugd" {
@ -178,6 +190,7 @@ module "load_balancer_target_debugd" {
lb_arn = aws_lb.front_end.arn
port = local.ports_debugd
tags = local.tags
healthcheck_protocol = "TCP"
}
module "load_balancer_target_konnectivity" {
@ -187,6 +200,7 @@ module "load_balancer_target_konnectivity" {
lb_arn = aws_lb.front_end.arn
port = local.ports_konnectivity
tags = local.tags
healthcheck_protocol = "TCP"
}
# TODO: Remove when development is more advanced
@ -198,6 +212,7 @@ module "load_balancer_target_ssh" {
lb_arn = aws_lb.front_end.arn
port = local.ports_ssh
tags = local.tags
healthcheck_protocol = "TCP"
}
module "instance_group_control_plane" {

View File

@ -16,7 +16,11 @@ resource "aws_lb_target_group" "front_end" {
health_check {
port = var.port
protocol = "TCP"
protocol = var.healthcheck_protocol
path = var.healthcheck_protocol == "HTTPS" ? var.healthcheck_path : null
interval = 10
healthy_threshold = 2
unhealthy_threshold = 2
}
lifecycle {

View File

@ -18,6 +18,18 @@ variable "lb_arn" {
description = "ARN of the load balancer."
}
variable "healthcheck_protocol" {
type = string
default = "TCP"
description = "Type of the load balancer target."
}
variable "healthcheck_path" {
type = string
default = ""
description = "Path for health check."
}
variable "tags" {
type = map(string)
description = "The tags to add to the loadbalancer."