Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Add health check for target instances
Browse files Browse the repository at this point in the history
Add health check for target instances
  • Loading branch information
rafaelmarques7 authored Jan 29, 2019
1 parent 11b5dc2 commit 55d042d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
8 changes: 8 additions & 0 deletions _alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ resource "aws_lb_target_group" "lb_target" {
port = 80
protocol = "HTTP"
vpc_id = "${aws_vpc.vpc.id}"

health_check = {
interval = 6
timeout = 5
path = "${var.health-check-path}"
port = "${var.health-check-port}"
matcher = "200-299"
}
}

resource "aws_lb_listener" "lb_listener" {
Expand Down
12 changes: 6 additions & 6 deletions _sg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ resource "aws_security_group" "sg" {
}

ingress {
protocol = "tcp"
from_port = "80"
to_port = "80"
protocol = "tcp"
from_port = "80"
to_port = "80"
security_groups = ["${aws_security_group.sg_alb.id}"]
}

ingress {
protocol = "tcp"
from_port = "443"
to_port = "443"
protocol = "tcp"
from_port = "443"
to_port = "443"
security_groups = ["${aws_security_group.sg_alb.id}"]
}

Expand Down
14 changes: 13 additions & 1 deletion _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,16 @@ variable "ssh-allowed-ips" {
description = "The list of IPs that are allowed to SSH into the instances"
type = "list"
default = []
}
}

variable "health-check-path" {
description = "The apps public sub domain name"
type = "string"
default = "/"
}

variable "health-check-port" {
description = "The apps public sub domain name"
type = "string"
default = "80"
}
12 changes: 6 additions & 6 deletions examples/engagement-app/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module "asg" {
source = "../../"
source = "../../"

aws-profile = "ds-web-products-staging"
aws-region = "eu-west-3"
instance-ami = "ami-0dd7e7ed60da8fb83"
user-data-script = "./user-data.sh"
asg-min-size = "2"
aws-region = "eu-west-3"
instance-ami = "ami-0dd7e7ed60da8fb83"
user-data-script = "./user-data.sh"
asg-min-size = "2"
asg-max-size = "4"
asg-def-size = "2"
alb-name = "rafa-ian-alb"
Expand All @@ -15,5 +15,5 @@ module "asg" {
launch-config-name = "rafa-ian-lc"
instance-associate-public-ip = "true"
iam-role-name = "engage-ECR-read"
ssh-allowed-ips = ["62.255.97.196/32", "62.255.97.197/32"]
ssh-allowed-ips = ["62.255.97.196/32", "62.6.58.84/32"]
}

0 comments on commit 55d042d

Please sign in to comment.