TargetGroupAttachment

class TargetGroupAttachment : KotlinCustomResource

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.

Properties

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

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 id: Output<String>
Link copied to clipboard
val port: Output<Int>?

The port on which targets receive traffic.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val targetGroupArn: Output<String>

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

Link copied to clipboard
val targetId: Output<String>

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:

Link copied to clipboard
val urn: Output<String>