Skip to content

Commit

Permalink
Merge pull request #11 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 0.6.0 -- new variable: health_check
  • Loading branch information
briskt authored Jul 16, 2024
2 parents acd2a18 + e65e8b0 commit 9727498
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,40 @@ Includes:
* CloudWatch Dashboard (optional)
* Cloudflare DNS Record (optional)
* Adminer database manager (optional)

## Inputs

- `health_check`

Defines health checks for load balancer target groups. See [AWS Documentation](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-health-checks.html) for details.

Example:

```hcl
health_check = {
enabled = true
healthy_threshold = 3
interval = 30
matcher = "200-399"
path = "/"
port = "traffic-port"
protocol = "HTTP"
timeout = 10
unhealthy_threshold = 3
}
```

- (TODO)

## Outputs

(TODO)


## Example

A working [example](https://github.com/silinternational/terraform-aws-ecs-app/tree/main/test) usage of this module is included in the source repository.

## More info

More information is available at the [Terraform Registry](https://registry.terraform.io/modules/silinternational/ecs-app/aws/latest)
18 changes: 14 additions & 4 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 Expand Up @@ -195,7 +205,7 @@ module "adminer" {
app_env = var.app_env
vpc_id = module.vpc.id
alb_https_listener_arn = module.alb.https_listener_arn
subdomain = "adminer"
subdomain = "adminer-${local.app_name_and_env}"
cloudflare_domain = var.domain_name
ecs_cluster_id = module.ecsasg.ecs_cluster_id
ecsServiceRole_arn = module.ecsasg.ecsServiceRole_arn
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 9727498

Please sign in to comment.