Resource: aws_vpclattice_target_group

Terraform resource for managing an AWS VPC Lattice Target Group.

Example Usage

Basic Usage

resource "aws_vpclattice_target_group" "example" {
  name = "example"
  type = "INSTANCE"

  config {
    vpc_identifier = aws_vpc.example.id

    port     = 443
    protocol = "HTTPS"
  }
}

Basic usage with Health check

resource "aws_vpclattice_target_group" "example" {
  name = "example"
  type = "IP"

  config {
    vpc_identifier = aws_vpc.example.id

    ip_address_type  = "IPV4"
    port             = 443
    protocol         = "HTTPS"
    protocol_version = "HTTP1"

    health_check {
      enabled                       = true
      health_check_interval_seconds = 20
      health_check_timeout_seconds  = 10
      healthy_threshold_count       = 7
      unhealthy_threshold_count     = 3

      matcher {
        value = "200-299"
      }

      path             = "/instance"
      port             = 80
      protocol         = "HTTP"
      protocol_version = "HTTP1"
    }
  }
}

ALB

If the type is ALB, health_check block is not supported.

resource "aws_vpclattice_target_group" "example" {
  name = "example"
  type = "ALB"

  config {
    vpc_identifier = aws_vpc.example.id

    port             = 443
    protocol         = "HTTPS"
    protocol_version = "HTTP1"
  }
}

Lambda

If the type is Lambda, config block is not supported.

resource "aws_vpclattice_target_group" "example" {
  name = "example"
  type = "LAMBDA"
}

Argument Reference

The following arguments are required:

The following arguments are optional:

Config (config) supports the following:

Health Check (health_check) supports the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import VPC Lattice Target Group using the id. For example:

import {
  to = aws_vpclattice_target_group.example
  id = "tg-0c11d4dc16ed96bdb"
}

Using terraform import, import VPC Lattice Target Group using the id. For example:

% terraform import aws_vpclattice_target_group.example tg-0c11d4dc16ed96bdb