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

From wikieduonline
Jump to navigation Jump to search
 
(7 intermediate revisions by 2 users not shown)
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 ==
Line 24: Line 40:
 
* <code>[[type]]</code>: The type of sticky sessions. The only current possible values are <code>lb_cookie</code>, <code>app_cookie</code> for ALBs, and <code>[[source_ip]]</code> for [[NLB]]s. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#type
 
* <code>[[type]]</code>: The type of sticky sessions. The only current possible values are <code>lb_cookie</code>, <code>app_cookie</code> for ALBs, and <code>[[source_ip]]</code> for [[NLB]]s. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#type
 
* <code>[[fixed_response]]</code> https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule#fixed_response
 
* <code>[[fixed_response]]</code> https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule#fixed_response
* <code>[[target_type]]</code>: <code>[[instance]]</code>, <code>[[ip]]</code> https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#target_type
+
* <code>[[target_type]]</code>: <code>[[instance]]</code> (default), <code>[[ip]]</code> https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#target_type
 
* <code>[[vpc_id]]</code>
 
* <code>[[vpc_id]]</code>
 
* <code>[[protocol]]</code>:<ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#protocol</ref> [[GENEVE]], HTTP, HTTPS, TCP, [[TCP_UDP]], TLS, or UDP
 
* <code>[[protocol]]</code>:<ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#protocol</ref> [[GENEVE]], HTTP, HTTPS, TCP, [[TCP_UDP]], TLS, or UDP
Line 47: Line 63:
 
* <code>[[draining]]</code>
 
* <code>[[draining]]</code>
 
* <code>[[aws_lb]]</code>
 
* <code>[[aws_lb]]</code>
 +
* <code>[[ResourceInUse]]</code>
  
 
== See also ==
 
== See also ==
 
* {{aws_lb_target_group}}
 
* {{aws_lb_target_group}}
* {{terraform AWS}}
+
* {{tf lb}}
* {{terraform aws resources}}
+
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 06:19, 31 May 2023

Examples[edit]

IP Target Group official example[edit]

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[edit]

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[edit]

Example Instance Target Group[edit]

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[edit]

See also[edit]

  • 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: