1. Packages
  2. AWS
  3. API Docs
  4. vpclattice
  5. TargetGroupAttachment
AWS v6.74.0 published on Wednesday, Mar 26, 2025 by Pulumi

aws.vpclattice.TargetGroupAttachment

Explore with Pulumi AI

Provides the ability to register a target with an AWS VPC Lattice Target Group.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.vpclattice.TargetGroupAttachment("example", {
    targetGroupIdentifier: exampleAwsVpclatticeTargetGroup.id,
    target: {
        id: exampleAwsLb.arn,
        port: 80,
    },
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.vpclattice.TargetGroupAttachment("example",
    target_group_identifier=example_aws_vpclattice_target_group["id"],
    target={
        "id": example_aws_lb["arn"],
        "port": 80,
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vpclattice.NewTargetGroupAttachment(ctx, "example", &vpclattice.TargetGroupAttachmentArgs{
			TargetGroupIdentifier: pulumi.Any(exampleAwsVpclatticeTargetGroup.Id),
			Target: &vpclattice.TargetGroupAttachmentTargetArgs{
				Id:   pulumi.Any(exampleAwsLb.Arn),
				Port: pulumi.Int(80),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.VpcLattice.TargetGroupAttachment("example", new()
    {
        TargetGroupIdentifier = exampleAwsVpclatticeTargetGroup.Id,
        Target = new Aws.VpcLattice.Inputs.TargetGroupAttachmentTargetArgs
        {
            Id = exampleAwsLb.Arn,
            Port = 80,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.vpclattice.TargetGroupAttachment;
import com.pulumi.aws.vpclattice.TargetGroupAttachmentArgs;
import com.pulumi.aws.vpclattice.inputs.TargetGroupAttachmentTargetArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new TargetGroupAttachment("example", TargetGroupAttachmentArgs.builder()
            .targetGroupIdentifier(exampleAwsVpclatticeTargetGroup.id())
            .target(TargetGroupAttachmentTargetArgs.builder()
                .id(exampleAwsLb.arn())
                .port(80)
                .build())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:vpclattice:TargetGroupAttachment
    properties:
      targetGroupIdentifier: ${exampleAwsVpclatticeTargetGroup.id}
      target:
        id: ${exampleAwsLb.arn}
        port: 80
Copy

Create TargetGroupAttachment Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new TargetGroupAttachment(name: string, args: TargetGroupAttachmentArgs, opts?: CustomResourceOptions);
@overload
def TargetGroupAttachment(resource_name: str,
                          args: TargetGroupAttachmentArgs,
                          opts: Optional[ResourceOptions] = None)

@overload
def TargetGroupAttachment(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          target: Optional[TargetGroupAttachmentTargetArgs] = None,
                          target_group_identifier: Optional[str] = None)
func NewTargetGroupAttachment(ctx *Context, name string, args TargetGroupAttachmentArgs, opts ...ResourceOption) (*TargetGroupAttachment, error)
public TargetGroupAttachment(string name, TargetGroupAttachmentArgs args, CustomResourceOptions? opts = null)
public TargetGroupAttachment(String name, TargetGroupAttachmentArgs args)
public TargetGroupAttachment(String name, TargetGroupAttachmentArgs args, CustomResourceOptions options)
type: aws:vpclattice:TargetGroupAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. TargetGroupAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. TargetGroupAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. TargetGroupAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. TargetGroupAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. TargetGroupAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment = new Aws.VpcLattice.TargetGroupAttachment("exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment", new()
{
    Target = new Aws.VpcLattice.Inputs.TargetGroupAttachmentTargetArgs
    {
        Id = "string",
        Port = 0,
    },
    TargetGroupIdentifier = "string",
});
Copy
example, err := vpclattice.NewTargetGroupAttachment(ctx, "exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment", &vpclattice.TargetGroupAttachmentArgs{
	Target: &vpclattice.TargetGroupAttachmentTargetArgs{
		Id:   pulumi.String("string"),
		Port: pulumi.Int(0),
	},
	TargetGroupIdentifier: pulumi.String("string"),
})
Copy
var exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment = new TargetGroupAttachment("exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment", TargetGroupAttachmentArgs.builder()
    .target(TargetGroupAttachmentTargetArgs.builder()
        .id("string")
        .port(0)
        .build())
    .targetGroupIdentifier("string")
    .build());
Copy
exampletarget_group_attachment_resource_resource_from_vpclatticetarget_group_attachment = aws.vpclattice.TargetGroupAttachment("exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment",
    target={
        "id": "string",
        "port": 0,
    },
    target_group_identifier="string")
Copy
const exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment = new aws.vpclattice.TargetGroupAttachment("exampletargetGroupAttachmentResourceResourceFromVpclatticetargetGroupAttachment", {
    target: {
        id: "string",
        port: 0,
    },
    targetGroupIdentifier: "string",
});
Copy
type: aws:vpclattice:TargetGroupAttachment
properties:
    target:
        id: string
        port: 0
    targetGroupIdentifier: string
Copy

TargetGroupAttachment Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The TargetGroupAttachment resource accepts the following input properties:

Target
This property is required.
Changes to this property will trigger replacement.
TargetGroupAttachmentTarget
The target.
TargetGroupIdentifier
This property is required.
Changes to this property will trigger replacement.
string
The ID or Amazon Resource Name (ARN) of the target group.
Target
This property is required.
Changes to this property will trigger replacement.
TargetGroupAttachmentTargetArgs
The target.
TargetGroupIdentifier
This property is required.
Changes to this property will trigger replacement.
string
The ID or Amazon Resource Name (ARN) of the target group.
target
This property is required.
Changes to this property will trigger replacement.
TargetGroupAttachmentTarget
The target.
targetGroupIdentifier
This property is required.
Changes to this property will trigger replacement.
String
The ID or Amazon Resource Name (ARN) of the target group.
target
This property is required.
Changes to this property will trigger replacement.
TargetGroupAttachmentTarget
The target.
targetGroupIdentifier
This property is required.
Changes to this property will trigger replacement.
string
The ID or Amazon Resource Name (ARN) of the target group.
target
This property is required.
Changes to this property will trigger replacement.
TargetGroupAttachmentTargetArgs
The target.
target_group_identifier
This property is required.
Changes to this property will trigger replacement.
str
The ID or Amazon Resource Name (ARN) of the target group.
target
This property is required.
Changes to this property will trigger replacement.
Property Map
The target.
targetGroupIdentifier
This property is required.
Changes to this property will trigger replacement.
String
The ID or Amazon Resource Name (ARN) of the target group.

Outputs

All input properties are implicitly available as output properties. Additionally, the TargetGroupAttachment resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing TargetGroupAttachment Resource

Get an existing TargetGroupAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: TargetGroupAttachmentState, opts?: CustomResourceOptions): TargetGroupAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        target: Optional[TargetGroupAttachmentTargetArgs] = None,
        target_group_identifier: Optional[str] = None) -> TargetGroupAttachment
func GetTargetGroupAttachment(ctx *Context, name string, id IDInput, state *TargetGroupAttachmentState, opts ...ResourceOption) (*TargetGroupAttachment, error)
public static TargetGroupAttachment Get(string name, Input<string> id, TargetGroupAttachmentState? state, CustomResourceOptions? opts = null)
public static TargetGroupAttachment get(String name, Output<String> id, TargetGroupAttachmentState state, CustomResourceOptions options)
resources:  _:    type: aws:vpclattice:TargetGroupAttachment    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Target Changes to this property will trigger replacement. TargetGroupAttachmentTarget
The target.
TargetGroupIdentifier Changes to this property will trigger replacement. string
The ID or Amazon Resource Name (ARN) of the target group.
Target Changes to this property will trigger replacement. TargetGroupAttachmentTargetArgs
The target.
TargetGroupIdentifier Changes to this property will trigger replacement. string
The ID or Amazon Resource Name (ARN) of the target group.
target Changes to this property will trigger replacement. TargetGroupAttachmentTarget
The target.
targetGroupIdentifier Changes to this property will trigger replacement. String
The ID or Amazon Resource Name (ARN) of the target group.
target Changes to this property will trigger replacement. TargetGroupAttachmentTarget
The target.
targetGroupIdentifier Changes to this property will trigger replacement. string
The ID or Amazon Resource Name (ARN) of the target group.
target Changes to this property will trigger replacement. TargetGroupAttachmentTargetArgs
The target.
target_group_identifier Changes to this property will trigger replacement. str
The ID or Amazon Resource Name (ARN) of the target group.
target Changes to this property will trigger replacement. Property Map
The target.
targetGroupIdentifier Changes to this property will trigger replacement. String
The ID or Amazon Resource Name (ARN) of the target group.

Supporting Types

TargetGroupAttachmentTarget
, TargetGroupAttachmentTargetArgs

Id
This property is required.
Changes to this property will trigger replacement.
string
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
Port Changes to this property will trigger replacement. int
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
Id
This property is required.
Changes to this property will trigger replacement.
string
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
Port Changes to this property will trigger replacement. int
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
id
This property is required.
Changes to this property will trigger replacement.
String
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
port Changes to this property will trigger replacement. Integer
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
id
This property is required.
Changes to this property will trigger replacement.
string
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
port Changes to this property will trigger replacement. number
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
port Changes to this property will trigger replacement. int
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.
id
This property is required.
Changes to this property will trigger replacement.
String
The ID of the target. If the target type of the target group is INSTANCE, this is an instance ID. If the target type is IP , this is an IP address. If the target type is LAMBDA, this is the ARN of the Lambda function. If the target type is ALB, this is the ARN of the Application Load Balancer.
port Changes to this property will trigger replacement. Number
This port is used for routing traffic to the target, and defaults to the target group port. However, you can override the default and specify a custom port.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.