Difference between revisions of "Terraform resource: aws lb target group"
Jump to navigation
Jump to search
↑ 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
(43 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
* Terraform resource: <code>aws_lb_target_group</code> <ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group</ref> | * Terraform resource: <code>aws_lb_target_group</code> <ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group</ref> | ||
+ | ** https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group | ||
+ | |||
+ | == 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 == | ||
+ | * <code>[[arn_suffix]]</code> - ARN suffix for use with CloudWatch Metrics. | ||
+ | * <code>[[arn]]</code> - ARN of the [[Target Group]] (matches id). | ||
+ | * <code>[[id]]</code> - ARN of the Target Group (matches arn). | ||
+ | * <code>[[name]]</code> - Name of the Target Group. | ||
+ | * <code>[[tags_all]]</code> - A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block. | ||
+ | * <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>[[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>[[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_version]]</code> (optional): [[HTTP1]] (default), [[GRPC]], [[HTTP2]] <ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#protocol_version</ref> | ||
+ | * <code>[[health_check]]</code><ref>https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#health_check</ref> | ||
+ | |||
+ | == 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 == | ||
+ | * <code>[[target_group_arn]]</code> | ||
+ | * <code>[[aws_lb_listener_rule]]</code> | ||
+ | * <code>[[draining]]</code> | ||
+ | * <code>[[aws_lb]]</code> | ||
+ | * <code>[[ResourceInUse]]</code> | ||
== See also == | == See also == | ||
− | * {{ | + | * {{aws_lb_target_group}} |
− | * {{ | + | * {{tf lb}} |
− | + | ||
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 06:19, 31 May 2023
- Terraform resource:
aws_lb_target_group
[1]
Contents
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]
arn_suffix
- ARN suffix for use with CloudWatch Metrics.arn
- ARN of the Target Group (matches id).id
- ARN of the Target Group (matches arn).name
- Name of the Target Group.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.type
: The type of sticky sessions. The only current possible values arelb_cookie
,app_cookie
for ALBs, andsource_ip
for NLBs. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#typefixed_response
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule#fixed_responsetarget_type
:instance
(default),ip
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group#target_typevpc_id
protocol
:[2] GENEVE, HTTP, HTTPS, TCP, TCP_UDP, TLS, or UDPprotocol_version
(optional): HTTP1 (default), GRPC, HTTP2 [3]health_check
[4]
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]
- Terraform AWS provider:
aws_lb_target_group
,target_group_arn
,aws lb target group - fixed response
- Terraform LB:
aws_lb
:aws_lb_listener
,aws_lb_listener_certificate
,aws_lb_listener_rule
,aws_lb_target_group
,aws_lb_target_group_attachment
,load_balancer_type
,aws lb listener: default action
,aws load balancer policy
Advertising: