Skip to content

Update alb.tf #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lab_jenkins_master_worker/alb.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// load balancer that is available to the public internet and designed to handle traffic from external users or the internet
resource "aws_lb" "application-lb" {
provider = aws.region-master
name = "jenkins-lb"
internal = false
internal = false // indicates that the load balancer should have internet access
load_balancer_type = "application"
security_groups = [aws_security_group.lb-sg.id]
subnets = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id]
tags = {
Name = "Jenkins-LB"
}
}

/* alb listens to incoming http traffic on port 80 and forwards traffic to the target group, which is configured with a health check and targets the "jenkins-master" EC2 instance on port 8080.
These resources enable traffic routing to and load balancing on the behalf of the jenkins application running on the "jenkins-master" EC2 instance in AWS.
resource "aws_lb_target_group" "app-lb-tg" {
provider = aws.region-master
name = "app-lb-tg"
Expand Down Expand Up @@ -41,6 +43,9 @@ resource "aws_lb_listener" "jenkins-listener-http" {
}
}

// health checks determine the availability of backend instances by sending a request to the specified instance and expecting a response within a certain time frame. If the target fails the health check, the load balancer will stop sending requests to unhealthy instances, helping ensure that traffic is only directed towards healthy instances, improving application reliability and availability.
Target groups are logical groupings of backend EC2 Instances that are registered with a load balancer. The load balancer uses target groups to distribute incoming requests across registered instances or targets based on the algorithm (round robin or least connections). Target groups ensure that traffic is distributed evenly across healthy instances and provides automatic failover by removing unhealthy instances from its load balancing rotation */

resource "aws_lb_target_group_attachment" "jenkins-master-attach" {
provider = aws.region-master
target_group_arn = aws_lb_target_group.app-lb-tg.arn
Expand Down