Difference between revisions of "Terraform resource: aws lb target group"

From wikieduonline
Jump to navigation Jump to search
Line 15: Line 15:
 
   cidr_block = "10.0.0.0/16"
 
   cidr_block = "10.0.0.0/16"
 
  }
 
  }
 +
 +
 +
=== host_header based [[forward]] ==
 +
resource "aws_lb_listener_rule" "your_host_rule" {
 +
  listener_arn = local.your_https_listener_arn
 +
  priority    = 401
 +
 +
  action {
 +
    type            = "[[forward]]"
 +
    target_group_arn = aws_lb_target_group.your_tg.arn
 +
  }
 +
 +
  condition {
 +
    host_header {
 +
      values = [var.yoururl]
 +
    }
 +
  }
  
 
== Attributes reference ==
 
== Attributes reference ==

Revision as of 07:44, 29 April 2023

Examples

IP Target Group official example

resource "aws_lb_target_group" "ip-example" {
 name        = "tf-example-lb-tg"
 port        = 80
 protocol    = "HTTP"
 target_type = "ip"
 vpc_id      = aws_vpc.main.id
}

resource "aws_vpc" "main" {
 cidr_block = "10.0.0.0/16"
}


= host_header based forward

resource "aws_lb_listener_rule" "your_host_rule" {
  listener_arn = local.your_https_listener_arn
  priority     = 401

  action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.your_tg.arn
  }

  condition {
    host_header {
      values = [var.yoururl]
    }
  }

Attributes reference

Example Instance Target Group

resource "aws_lb_target_group" "test" {
  name     = "tf-example-lb-tg"
  port     = 80
  protocol = "HTTP"
  vpc_id   = aws_vpc.main.id
} 

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

Related terms

See also

  • https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group
  • https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#protocol
  • https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#protocol_version
  • https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#health_check
  • Advertising: