Skip to content

Commit

Permalink
Initial Implementation of #46
Browse files Browse the repository at this point in the history
  • Loading branch information
robg-test committed May 15, 2023
1 parent 81c040d commit f892a66
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
48 changes: 48 additions & 0 deletions modules/aws/elb/main.tf
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"
}
}
27 changes: 27 additions & 0 deletions modules/aws/elb/variables.tf
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"
}

0 comments on commit f892a66

Please sign in to comment.