Package com.pulumi.aws.lb
Class TargetGroupAttachment
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.lb.TargetGroupAttachment
-
public class TargetGroupAttachment extends com.pulumi.resources.CustomResourceProvides 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
### Lambda Targetpackage 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.ArrayList; import java.util.Arrays; 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 test = new TargetGroupAttachment("test", TargetGroupAttachmentArgs.builder() .targetGroupArn(testTargetGroup.arn()) .targetId(testInstance.id()) .port(80) .build()); } }
### Target using QUICpackage 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.ArrayList; import java.util.Arrays; 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 test = new TargetGroup("test", TargetGroupArgs.builder() .name("test") .targetType("lambda") .build()); var testFunction = new Function("testFunction"); var withLb = new Permission("withLb", PermissionArgs.builder() .statementId("AllowExecutionFromlb") .action("lambda:InvokeFunction") .function(testFunction.name()) .principal("elasticloadbalancing.amazonaws.com") .sourceArn(test.arn()) .build()); var testTargetGroupAttachment = new TargetGroupAttachment("testTargetGroupAttachment", TargetGroupAttachmentArgs.builder() .targetGroupArn(test.arn()) .targetId(testFunction.arn()) .build(), CustomResourceOptions.builder() .dependsOn(withLb) .build()); } }
## Import ### Identity Schema #### Required * `targetGroupArn` - (String) ARN of the target group. * `targetId` - (String) ID of the target (instance ID, IP address, Lambda ARN, or ALB ARN). #### Optional * `port` - (Number) Port on which targets receive traffic. * `availabilityZone` - (String) Availability zone where the target is registered. * `quicServerId` - (String) QUIC server ID for the target. * `accountId` - (String) AWS Account where this resource is managed. * `region` - (String) Region where this resource is managed. Using `pulumi import`, import Target Group Attachments using the same format. For example: ```sh $ pulumi import aws:lb/targetGroupAttachment:TargetGroupAttachment example arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tg/abc123,i-0123456789abcdef0,8080 ```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.ec2.Instance; import com.pulumi.aws.lb.TargetGroupAttachment; import com.pulumi.aws.lb.TargetGroupAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; 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 test = new TargetGroup("test", TargetGroupArgs.builder() .name("test") .port(443) .protocol("QUIC") .build()); var testInstance = new Instance("testInstance"); var testTargetGroupAttachment = new TargetGroupAttachment("testTargetGroupAttachment", TargetGroupAttachmentArgs.builder() .targetGroupArn(test.arn()) .targetId(testInstance.id()) .port(443) .quicServerId("0x1a2b3c4d5e6f7a8b") .build()); } }
-
-
Constructor Summary
Constructors Constructor Description TargetGroupAttachment(java.lang.String name)TargetGroupAttachment(java.lang.String name, TargetGroupAttachmentArgs args)TargetGroupAttachment(java.lang.String name, TargetGroupAttachmentArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.util.Optional<java.lang.String>>availabilityZone()static TargetGroupAttachmentget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, TargetGroupAttachmentState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.util.Optional<java.lang.Integer>>port()com.pulumi.core.Output<java.util.Optional<java.lang.String>>quicServerId()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.lang.String>targetGroupArn()com.pulumi.core.Output<java.lang.String>targetId()
-
-
-
Constructor Detail
-
TargetGroupAttachment
public TargetGroupAttachment(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
TargetGroupAttachment
public TargetGroupAttachment(java.lang.String name, TargetGroupAttachmentArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
TargetGroupAttachment
public TargetGroupAttachment(java.lang.String name, TargetGroupAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
availabilityZone
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> availabilityZone()
- Returns:
- 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`.
-
port
public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> port()
- Returns:
- The port on which targets receive traffic.
-
quicServerId
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> quicServerId()
- Returns:
- Server ID for the targets, consisting of the 0x prefix followed by 16 hexadecimal characters. The value must be unique at the listener level. Required if `aws.lb.TargetGroup` protocol is `QUIC` or `TCP_QUIC`. Not valid with other protocols. Forces replacement if modified.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
targetGroupArn
public com.pulumi.core.Output<java.lang.String> targetGroupArn()
- Returns:
- The ARN of the target group with which to register targets.
-
targetId
public com.pulumi.core.Output<java.lang.String> targetId()
- Returns:
- 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:
-
get
public static TargetGroupAttachment get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable TargetGroupAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-