Skip to content

Commit

Permalink
add new variable, health_check, to allow ELB health checks configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Jul 15, 2024
1 parent 235fe52 commit c7e4061
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,19 @@ resource "aws_alb_target_group" "tg" {
type = "lb_cookie"
}

health_check {
path = "/"
matcher = "302"
dynamic "health_check" {
for_each = [var.health_check]
content {
enabled = try(health_check.value.enabled, null)
healthy_threshold = try(health_check.value.healthy_threshold, null)
interval = try(health_check.value.interval, null)
matcher = try(health_check.value.matcher, null)
path = try(health_check.value.path, null)
port = try(health_check.value.port, null)
protocol = try(health_check.value.protocol, null)
timeout = try(health_check.value.timeout, null)
unhealthy_threshold = try(health_check.value.unhealthy_threshold, null)
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions test/test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ module "full" {
instance_type = "t3.micro"
create_adminer = true
enable_adminer = true
health_check = {
enabled = true
healthy_threshold = 3
interval = 30
matcher = "200-399"
path = "/"
port = "traffic-port"
protocol = "HTTP"
timeout = 10
unhealthy_threshold = 3
}
}

provider "aws" {
Expand Down
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ variable "default_cert_domain_name" {
type = string
}

variable "health_check" {
description = "Elastic Load Balancer health check configuration"
type = map(string)
default = {
path = "/"
matcher = "200-399"
}
}

/*
* Database configuration
Expand Down

0 comments on commit c7e4061

Please sign in to comment.