Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform how to register known private ip address in target group of type "ip"

In Terraform

How can register known private ip addresses in target group of type "ip". Below is my current code.

resource "aws_alb_target_group" "default" {
  name        = "target group name"
  port        = var.container_port
  protocol    = "HTTP"
  target_type = "ip"
  vpc_id      = data.terraform_remote_state.network.outputs.vpc_id

  health_check {
    path     = var.health_check_path
    protocol = "HTTP"
    port     = var.target_group_port
    interval = 60
  }

  tags = var.tags
 
}
like image 435
BalaB Avatar asked Oct 28 '25 21:10

BalaB


1 Answers

You use aws_lb_target_group_attachment for that.

For example:

resource "aws_lb_target_group_attachment" "test" {
  target_group_arn = aws_alb_target_group.default.arn
  target_id        = instance-ip-address
  port             = 80
}
like image 115
Marcin Avatar answered Oct 30 '25 11:10

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!