AWS Elastic Load Balancing V2 Target Group Attachment

This page shows how to write Terraform and CloudFormation for Elastic Load Balancing V2 Target Group Attachment and write them securely.

code-icon

Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.

get-started-button

Terraform Example (aws_lb_target_group_attachment)

Provides the ability to register instances and containers with an Application Load Balancer (ALB) or Network Load Balancer (NLB) target group. For attaching resources with Elastic Load Balancer (ELB), see the aws_elb_attachment resource.

Note: aws_alb_target_group_attachment is known as aws_lb_target_group_attachment. The functionality is identical.

Parameters

Example Usage (from GitHub)

github-iconyoen1905/Final_Terraform
resource "aws_lb_target_group_attachment" "Final_alb_tg_ass_a" {
  target_group_arn = aws_lb_target_group.Final_alb_tg.arn
  target_id        = aws_instance.Final_web[0].id
  port             = 80
}

github-iconivanykp/ci
resource "aws_lb_target_group_attachment" "tga_template_a" {
    target_group_arn = aws_lb_target_group.ltg_template.arn
    target_id = var.tga_target_a.id
}


CloudFormation Example (AWS::ElasticLoadBalancingV2::TargetGroup Matcher)

Specifies the HTTP codes that healthy targets must use when responding to an HTTP health check.

Parameters

GrpcCode You can specify values between 0 and 99. You can specify multiple values (for example, "0,1") or a range of values (for example, "0-5"). The default value is 12.
Required: No
Type: String
Update requires: No interruption

HttpCode For Application Load Balancers, you can specify values between 200 and 499, and the default value is 200. You can specify multiple values (for example, "200,202") or a range of values (for example, "200-299").
For Network Load Balancers and Gateway Load Balancers, this must be "200–399".
Note that when using shorthand syntax, some values such as commas need to be escaped.
Required: No
Type: String
Update requires: No interruption

Frequently asked questions

What is AWS Elastic Load Balancing V2 Target Group Attachment?

AWS Elastic Load Balancing V2 Target Group Attachment is a resource for Elastic Load Balancing V2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Elastic Load Balancing V2 Target Group Attachment?

For Terraform, the yoen1905/Final_Terraform and ivanykp/ci source code examples are useful. See the Terraform Example section for further details.