TargetGroupAttachmentArgs

data class TargetGroupAttachmentArgs(val availabilityZone: Output<String>? = null, val port: Output<Int>? = null, val targetGroupArn: Output<String>? = null, val targetId: Output<String>? = null) : ConvertibleToJava<TargetGroupAttachmentArgs>

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.TargetGroupAttachment is known as aws.lb.TargetGroupAttachment. The functionality is identical.

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lb.TargetGroup;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.lb.TargetGroupAttachment;
import com.pulumi.aws.lb.TargetGroupAttachmentArgs;
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 testTargetGroup = new TargetGroup("testTargetGroup");
var testInstance = new Instance("testInstance");
var testTargetGroupAttachment = new TargetGroupAttachment("testTargetGroupAttachment", TargetGroupAttachmentArgs.builder()
.targetGroupArn(testTargetGroup.arn())
.targetId(testInstance.id())
.port(80)
.build());
}
}

Lambda Target

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lb.TargetGroup;
import com.pulumi.aws.lb.TargetGroupArgs;
import com.pulumi.aws.lambda.Function;
import com.pulumi.aws.lambda.Permission;
import com.pulumi.aws.lambda.PermissionArgs;
import com.pulumi.aws.lb.TargetGroupAttachment;
import com.pulumi.aws.lb.TargetGroupAttachmentArgs;
import com.pulumi.resources.CustomResourceOptions;
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 testTargetGroup = new TargetGroup("testTargetGroup", TargetGroupArgs.builder()
.targetType("lambda")
.build());
var testFunction = new Function("testFunction");
var withLb = new Permission("withLb", PermissionArgs.builder()
.action("lambda:InvokeFunction")
.function(testFunction.name())
.principal("elasticloadbalancing.amazonaws.com")
.sourceArn(testTargetGroup.arn())
.build());
var testTargetGroupAttachment = new TargetGroupAttachment("testTargetGroupAttachment", TargetGroupAttachmentArgs.builder()
.targetGroupArn(testTargetGroup.arn())
.targetId(testFunction.arn())
.build(), CustomResourceOptions.builder()
.dependsOn(withLb)
.build());
}
}

Registering Multiple Targets

No Java example available.

Import

You cannot import Target Group Attachments.

Constructors

Link copied to clipboard
fun TargetGroupAttachmentArgs(availabilityZone: Output<String>? = null, port: Output<Int>? = null, targetGroupArn: Output<String>? = null, targetId: Output<String>? = null)

Functions

Link copied to clipboard
open override fun toJava(): TargetGroupAttachmentArgs

Properties

Link copied to clipboard
val availabilityZone: Output<String>? = null

The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to all.

Link copied to clipboard
val port: Output<Int>? = null

The port on which targets receive traffic.

Link copied to clipboard
val targetGroupArn: Output<String>? = null

The ARN of the target group with which to register targets.

Link copied to clipboard
val targetId: Output<String>? = null

The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is ip, specify an IP address. If the target type is lambda, specify the Lambda function ARN. If the target type is alb, specify the ALB ARN. The following arguments are optional: