-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
resource "aws_lb_target_group" "mdm_target_group" { | ||
name = "${var.lb_name}-target-group" | ||
port = var.application_port | ||
protocol = var.application_http_protocol | ||
target_type = "ip" # set target_type to ip | ||
vpc_id = var.vpc_id | ||
|
||
stickiness { | ||
enabled = true | ||
type = "lb_cookie" | ||
cookie_name = "mdm_cookie" | ||
} | ||
|
||
health_check { | ||
enabled = true | ||
healthy_threshold = 3 | ||
interval = 50 | ||
matcher = 200 | ||
path = "/api/authorities" | ||
port = "traffic-port" | ||
protocol = var.application_http_protocol | ||
timeout = 10 | ||
unhealthy_threshold = 3 | ||
} | ||
} | ||
|
||
|
||
resource "aws_lb" "aws_lb" { | ||
name = "${var.lb_name}-lb" | ||
internal = var.internal | ||
load_balancer_type = "application" | ||
security_groups = var.security_group_id | ||
subnets = var.subnet_ids | ||
enable_deletion_protection = true | ||
tags = { | ||
Name = "${var.lb_name}-lb" | ||
} | ||
} | ||
|
||
resource "aws_lb_listener" "mdm_lb_listener" { | ||
load_balancer_arn = aws_lb.aws_lb.arn | ||
port = var.application_port | ||
protocol = var.application_http_protocol | ||
default_action { | ||
target_group_arn = aws_lb_target_group.mdm_target_group.arn | ||
type = "forward" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
variable "application_port" { | ||
default = "The port of the application to forward traffic to" | ||
} | ||
|
||
variable "application_http_protocol" { | ||
default = "The protocol over which to forward traffic. Used for the health check and the and the load balancer itself " | ||
} | ||
|
||
variable "vpc_id" { | ||
description = "The id of the VPC to create the ELB In this is provided by the VPC Module" | ||
} | ||
|
||
variable "internal" { | ||
description = "If the ELB is internally facing or externally facing" | ||
} | ||
|
||
variable "lb_name" { | ||
description = "The name of the load balancer" | ||
} | ||
|
||
variable "security_group_id" { | ||
default = "The security group of which this LB will belong to" | ||
} | ||
|
||
variable "subnet_ids" { | ||
default = "The Subnets in which this LB will operate" | ||
} |