Skip to content

Instantly share code, notes, and snippets.

@SharmilaS22
Created June 18, 2023 15:13
Show Gist options
  • Select an option

  • Save SharmilaS22/447aed1a594e359c959c4c2d1d83e03a to your computer and use it in GitHub Desktop.

Select an option

Save SharmilaS22/447aed1a594e359c959c4c2d1d83e03a to your computer and use it in GitHub Desktop.
Application Load balancer open to internet, with a target group
resource "aws_lb" "sh_lb" {
name = "sharmi-lb-asg"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.sh_sg_for_elb.id]
subnets = [aws_subnet.sh_subnet_1.id, aws_subnet.sh_subnet_1a.id]
depends_on = [aws_internet_gateway.sh_gw]
}
resource "aws_lb_target_group" "sh_alb_tg" {
name = "sh-tf-lb-alb-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.sh_main.id
}
resource "aws_lb_listener" "sh_front_end" {
load_balancer_arn = aws_lb.sh_lb.arn
port = "80"
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.sh_alb_tg.arn
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment