Class TargetGroupAttachment


  • public class TargetGroupAttachment
    extends com.pulumi.resources.CustomResource
    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 <!--Start PulumiCodeChooser -->
     
     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 test = new TargetGroupAttachment("test", TargetGroupAttachmentArgs.builder()
                 .targetGroupArn(testTargetGroup.arn())
                 .targetId(testInstance.id())
                 .port(80)
                 .build());
     
         }
     }
     
     
    <!--End PulumiCodeChooser --> ### Lambda Target <!--Start PulumiCodeChooser -->
     
     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 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());
     
         }
     }
     
     
    <!--End PulumiCodeChooser --> ### Registering Multiple Targets <!--Start PulumiCodeChooser --> <!--End PulumiCodeChooser --> ## Import You cannot import Target Group Attachments.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • 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 TargetGroupAttachment get​(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.lang.String> targetGroupArn()  
      com.pulumi.core.Output<java.lang.String> targetId()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
      • 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.