JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.795

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.services.elasticloadbalancingv2

Interface AmazonElasticLoadBalancing

  • All Known Subinterfaces:
    AmazonElasticLoadBalancingAsync
    All Known Implementing Classes:
    AbstractAmazonElasticLoadBalancing, AbstractAmazonElasticLoadBalancingAsync, AmazonElasticLoadBalancingAsyncClient, AmazonElasticLoadBalancingClient


    @Generated(value="com.amazonaws:aws-java-sdk-code-generator")
    public interface AmazonElasticLoadBalancing
    Interface for accessing Elastic Load Balancing v2.

    Note: Do not directly implement this interface, new methods are added to it regularly. Extend from AbstractAmazonElasticLoadBalancing instead.

    Elastic Load Balancing

    A load balancer distributes incoming traffic across targets, such as your EC2 instances. This enables you to increase the availability of your application. The load balancer also monitors the health of its registered targets and ensures that it routes traffic only to healthy targets. You configure your load balancer to accept incoming traffic by specifying one or more listeners, which are configured with a protocol and port number for connections from clients to the load balancer. You configure a target group with a protocol and port number for connections from the load balancer to the targets, and with health check settings to be used when checking the health status of the targets.

    Elastic Load Balancing supports the following types of load balancers: Application Load Balancers, Network Load Balancers, Gateway Load Balancers, and Classic Load Balancers. This reference covers the following load balancer types:

    • Application Load Balancer - Operates at the application layer (layer 7) and supports HTTP and HTTPS.

    • Network Load Balancer - Operates at the transport layer (layer 4) and supports TCP, TLS, and UDP.

    • Gateway Load Balancer - Operates at the network layer (layer 3).

    For more information, see the Elastic Load Balancing User Guide.

    All Elastic Load Balancing operations are idempotent, which means that they complete at most one time. If you repeat an operation, it succeeds.

    • Method Detail

      • setEndpoint

        @Deprecated
        void setEndpoint(String endpoint)
        Deprecated. use AwsClientBuilder#setEndpointConfiguration(AwsClientBuilder.EndpointConfiguration) for example: builder.setEndpointConfiguration(new EndpointConfiguration(endpoint, signingRegion));
        Overrides the default endpoint for this client ("elasticloadbalancing.us-east-1.amazonaws.com"). Callers can use this method to control which AWS region they want to work with.

        Callers can pass in just the endpoint (ex: "elasticloadbalancing.us-east-1.amazonaws.com") or a full URL, including the protocol (ex: "elasticloadbalancing.us-east-1.amazonaws.com"). If the protocol is not specified here, the default protocol from this client's ClientConfiguration will be used, which by default is HTTPS.

        For more information on using AWS regions with the AWS SDK for Java, and a complete list of all available endpoints for all AWS services, see: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html#region-selection- choose-endpoint

        This method is not threadsafe. An endpoint should be configured when the client is created and before any service requests are made. Changing it afterwards creates inevitable race conditions for any service requests in transit or retrying.

        Parameters:
        endpoint - The endpoint (ex: "elasticloadbalancing.us-east-1.amazonaws.com") or a full URL, including the protocol (ex: "elasticloadbalancing.us-east-1.amazonaws.com") of the region specific AWS endpoint this client will communicate with.
      • addTags

        AddTagsResult addTags(AddTagsRequest addTagsRequest)

        Adds the specified tags to the specified Elastic Load Balancing resource. You can tag your Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, trust stores, listeners, and rules.

        Each tag consists of a key and an optional value. If a resource already has a tag with the same key, AddTags updates its value.

        Parameters:
        addTagsRequest -
        Returns:
        Result of the AddTags operation returned by the service.
        Throws:
        DuplicateTagKeysException - A tag key was specified more than once.
        TooManyTagsException - You've reached the limit on the number of tags for this resource.
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        TargetGroupNotFoundException - The specified target group does not exist.
        ListenerNotFoundException - The specified listener does not exist.
        RuleNotFoundException - The specified rule does not exist.
        TrustStoreNotFoundException - The specified trust store does not exist.
        See Also:
        AWS API Documentation

        Samples:
        • To add tags to a load balancer
          This example adds two tags to the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          AddTagsRequest request = new AddTagsRequest().withLoadBalancerNames("my-load-balancer").withTags(new Tag().withKey("project").withValue("lima"),
           new Tag().withKey("department").withValue("digital-media"));
          AddTagsResult response = client.addTags(request);
      • createLoadBalancer

        CreateLoadBalancerResult createLoadBalancer(CreateLoadBalancerRequest createLoadBalancerRequest)

        Creates an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.

        For more information, see the following:

        This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple load balancers with the same settings, each call succeeds.

        Parameters:
        createLoadBalancerRequest -
        Returns:
        Result of the CreateLoadBalancer operation returned by the service.
        Throws:
        DuplicateLoadBalancerNameException - A load balancer with the specified name already exists.
        TooManyLoadBalancersException - You've reached the limit on the number of load balancers for your Amazon Web Services account.
        InvalidConfigurationRequestException - The requested configuration is not valid.
        SubnetNotFoundException - The specified subnet does not exist.
        InvalidSubnetException - The specified subnet is out of available addresses.
        InvalidSecurityGroupException - The specified security group does not exist.
        InvalidSchemeException - The requested scheme is not valid.
        TooManyTagsException - You've reached the limit on the number of tags for this resource.
        DuplicateTagKeysException - A tag key was specified more than once.
        ResourceInUseException - A specified resource is in use.
        AllocationIdNotFoundException - The specified allocation ID does not exist.
        AvailabilityZoneNotSupportedException - The specified Availability Zone is not supported.
        OperationNotPermittedException - This operation is not allowed.
        See Also:
        AWS API Documentation

        Samples:
        • To create an internal load balancer
          This example creates an internal load balancer with an HTTP listener in a VPC.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          CreateLoadBalancerRequest request = new CreateLoadBalancerRequest().withLoadBalancerName("my-load-balancer")
           .withListeners(new Listener().withProtocol("HTTP").withLoadBalancerPort(80).withInstanceProtocol("HTTP").withInstancePort(80))
           .withSubnets("subnet-15aaab61").withSecurityGroups("sg-a61988c3");
          CreateLoadBalancerResult response = client.createLoadBalancer(request);AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          CreateLoadBalancerRequest request = new CreateLoadBalancerRequest().withLoadBalancerName("my-load-balancer")
           .withListeners(new Listener().withProtocol("HTTP").withLoadBalancerPort(80).withInstanceProtocol("HTTP").withInstancePort(80))
           .withAvailabilityZones("us-west-2a");
          CreateLoadBalancerResult response = client.createLoadBalancer(request);AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          CreateLoadBalancerRequest request = new CreateLoadBalancerRequest()
           .withLoadBalancerName("my-load-balancer")
           .withListeners(
           new Listener().withProtocol("HTTP").withLoadBalancerPort(80).withInstanceProtocol("HTTP").withInstancePort(80),
           new Listener().withProtocol("HTTPS").withLoadBalancerPort(443).withInstanceProtocol("HTTP").withInstancePort(80)
           .withSSLCertificateId("arn:aws:iam::123456789012:server-certificate/my-server-cert")).withSubnets("subnet-15aaab61")
           .withSecurityGroups("sg-a61988c3");
          CreateLoadBalancerResult response = client.createLoadBalancer(request);AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          CreateLoadBalancerRequest request = new CreateLoadBalancerRequest()
           .withLoadBalancerName("my-load-balancer")
           .withListeners(
           new Listener().withProtocol("HTTP").withLoadBalancerPort(80).withInstanceProtocol("HTTP").withInstancePort(80),
           new Listener().withProtocol("HTTPS").withLoadBalancerPort(443).withInstanceProtocol("HTTP").withInstancePort(80)
           .withSSLCertificateId("arn:aws:iam::123456789012:server-certificate/my-server-cert")).withAvailabilityZones("us-west-2a");
          CreateLoadBalancerResult response = client.createLoadBalancer(request);AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          CreateLoadBalancerRequest request = new CreateLoadBalancerRequest().withLoadBalancerName("my-load-balancer")
           .withListeners(new Listener().withProtocol("HTTP").withLoadBalancerPort(80).withInstanceProtocol("HTTP").withInstancePort(80))
           .withSubnets("subnet-15aaab61").withSecurityGroups("sg-a61988c3").withScheme("internal");
          CreateLoadBalancerResult response = client.createLoadBalancer(request);
      • deleteLoadBalancer

        DeleteLoadBalancerResult deleteLoadBalancer(DeleteLoadBalancerRequest deleteLoadBalancerRequest)

        Deletes the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer. Deleting a load balancer also deletes its listeners.

        You can't delete a load balancer if deletion protection is enabled. If the load balancer does not exist or has already been deleted, the call succeeds.

        Deleting a load balancer does not affect its registered targets. For example, your EC2 instances continue to run and are still registered to their target groups. If you no longer need these EC2 instances, you can stop or terminate them.

        Parameters:
        deleteLoadBalancerRequest -
        Returns:
        Result of the DeleteLoadBalancer operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        OperationNotPermittedException - This operation is not allowed.
        ResourceInUseException - A specified resource is in use.
        See Also:
        AWS API Documentation

        Samples:
        • To delete a load balancer
          This example deletes the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          DeleteLoadBalancerRequest request = new DeleteLoadBalancerRequest().withLoadBalancerName("my-load-balancer");
          DeleteLoadBalancerResult response = client.deleteLoadBalancer(request);
      • deleteTargetGroup

        DeleteTargetGroupResult deleteTargetGroup(DeleteTargetGroupRequest deleteTargetGroupRequest)

        Deletes the specified target group.

        You can delete a target group if it is not referenced by any actions. Deleting a target group also deletes any associated health checks. Deleting a target group does not affect its registered targets. For example, any EC2 instances continue to run until you stop or terminate them.

        Parameters:
        deleteTargetGroupRequest -
        Returns:
        Result of the DeleteTargetGroup operation returned by the service.
        Throws:
        ResourceInUseException - A specified resource is in use.
        See Also:
        AWS API Documentation
      • deregisterTargets

        DeregisterTargetsResult deregisterTargets(DeregisterTargetsRequest deregisterTargetsRequest)

        Deregisters the specified targets from the specified target group. After the targets are deregistered, they no longer receive traffic from the load balancer.

        The load balancer stops sending requests to targets that are deregistering, but uses connection draining to ensure that in-flight traffic completes on the existing connections. This deregistration delay is configured by default but can be updated for each target group.

        For more information, see the following:

        Note: If the specified target does not exist, the action returns successfully.

        Parameters:
        deregisterTargetsRequest -
        Returns:
        Result of the DeregisterTargets operation returned by the service.
        Throws:
        TargetGroupNotFoundException - The specified target group does not exist.
        InvalidTargetException - The specified target does not exist, is not in the same VPC as the target group, or has an unsupported instance type.
        See Also:
        AWS API Documentation
      • describeListenerCertificates

        DescribeListenerCertificatesResult describeListenerCertificates(DescribeListenerCertificatesRequest describeListenerCertificatesRequest)

        Describes the default certificate and the certificate list for the specified HTTPS or TLS listener.

        If the default certificate is also in the certificate list, it appears twice in the results (once with IsDefault set to true and once with IsDefault set to false).

        For more information, see SSL certificates in the Application Load Balancers Guide or Server certificates in the Network Load Balancers Guide.

        Parameters:
        describeListenerCertificatesRequest -
        Returns:
        Result of the DescribeListenerCertificates operation returned by the service.
        Throws:
        ListenerNotFoundException - The specified listener does not exist.
        See Also:
        AWS API Documentation
      • describeLoadBalancerAttributes

        DescribeLoadBalancerAttributesResult describeLoadBalancerAttributes(DescribeLoadBalancerAttributesRequest describeLoadBalancerAttributesRequest)

        Describes the attributes for the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.

        For more information, see the following:

        Parameters:
        describeLoadBalancerAttributesRequest -
        Returns:
        Result of the DescribeLoadBalancerAttributes operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        See Also:
        AWS API Documentation

        Samples:
        • To describe the attributes of a load balancer
          This example describes the attributes of the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          DescribeLoadBalancerAttributesRequest request = new DescribeLoadBalancerAttributesRequest().withLoadBalancerName("my-load-balancer");
          DescribeLoadBalancerAttributesResult response = client.describeLoadBalancerAttributes(request);
      • describeLoadBalancers

        DescribeLoadBalancersResult describeLoadBalancers(DescribeLoadBalancersRequest describeLoadBalancersRequest)

        Describes the specified load balancers or all of your load balancers.

        Parameters:
        describeLoadBalancersRequest -
        Returns:
        Result of the DescribeLoadBalancers operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        See Also:
        AWS API Documentation

        Samples:
        • To describe one of your load balancers
          This example describes the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest().withLoadBalancerNames("my-load-balancer");
          DescribeLoadBalancersResult response = client.describeLoadBalancers(request);
      • describeTags

        DescribeTagsResult describeTags(DescribeTagsRequest describeTagsRequest)

        Describes the tags for the specified Elastic Load Balancing resources. You can describe the tags for one or more Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, listeners, or rules.

        Parameters:
        describeTagsRequest -
        Returns:
        Result of the DescribeTags operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        TargetGroupNotFoundException - The specified target group does not exist.
        ListenerNotFoundException - The specified listener does not exist.
        RuleNotFoundException - The specified rule does not exist.
        TrustStoreNotFoundException - The specified trust store does not exist.
        See Also:
        AWS API Documentation

        Samples:
        • To describe the tags for a load balancer
          This example describes the tags for the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          DescribeTagsRequest request = new DescribeTagsRequest().withLoadBalancerNames("my-load-balancer");
          DescribeTagsResult response = client.describeTags(request);
      • describeTargetGroups

        DescribeTargetGroupsResult describeTargetGroups(DescribeTargetGroupsRequest describeTargetGroupsRequest)

        Describes the specified target groups or all of your target groups. By default, all target groups are described. Alternatively, you can specify one of the following to filter the results: the ARN of the load balancer, the names of one or more target groups, or the ARNs of one or more target groups.

        Parameters:
        describeTargetGroupsRequest -
        Returns:
        Result of the DescribeTargetGroups operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        TargetGroupNotFoundException - The specified target group does not exist.
        See Also:
        AWS API Documentation
      • modifyLoadBalancerAttributes

        ModifyLoadBalancerAttributesResult modifyLoadBalancerAttributes(ModifyLoadBalancerAttributesRequest modifyLoadBalancerAttributesRequest)

        Modifies the specified attributes of the specified Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.

        If any of the specified attributes can't be modified as requested, the call fails. Any existing attributes that you do not modify retain their current values.

        Parameters:
        modifyLoadBalancerAttributesRequest -
        Returns:
        Result of the ModifyLoadBalancerAttributes operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        InvalidConfigurationRequestException - The requested configuration is not valid.
        See Also:
        AWS API Documentation

        Samples:
        • To enable connection draining
          This example enables connection draining for the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          ModifyLoadBalancerAttributesRequest request = new ModifyLoadBalancerAttributesRequest().withLoadBalancerName("my-load-balancer")
           .withLoadBalancerAttributes(new LoadBalancerAttributes().withCrossZoneLoadBalancing(new CrossZoneLoadBalancing().withEnabled(true)));
          ModifyLoadBalancerAttributesResult response = client.modifyLoadBalancerAttributes(request);AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          ModifyLoadBalancerAttributesRequest request = new ModifyLoadBalancerAttributesRequest().withLoadBalancerName("my-load-balancer")
           .withLoadBalancerAttributes(new LoadBalancerAttributes().withConnectionDraining(new ConnectionDraining().withEnabled(true).withTimeout(300)));
          ModifyLoadBalancerAttributesResult response = client.modifyLoadBalancerAttributes(request);
      • registerTargets

        RegisterTargetsResult registerTargets(RegisterTargetsRequest registerTargetsRequest)

        Registers the specified targets with the specified target group.

        If the target is an EC2 instance, it must be in the running state when you register it.

        By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports.

        With a Network Load Balancer, you cannot register instances by instance ID if they have the following instance types: C1, CC1, CC2, CG1, CG2, CR1, CS1, G1, G2, HI1, HS1, M1, M2, M3, and T1. You can register instances of these types by IP address.

        Parameters:
        registerTargetsRequest -
        Returns:
        Result of the RegisterTargets operation returned by the service.
        Throws:
        TargetGroupNotFoundException - The specified target group does not exist.
        TooManyTargetsException - You've reached the limit on the number of targets.
        InvalidTargetException - The specified target does not exist, is not in the same VPC as the target group, or has an unsupported instance type.
        TooManyRegistrationsForTargetIdException - You've reached the limit on the number of times a target can be registered with a load balancer.
        See Also:
        AWS API Documentation
      • removeTags

        RemoveTagsResult removeTags(RemoveTagsRequest removeTagsRequest)

        Removes the specified tags from the specified Elastic Load Balancing resources. You can remove the tags for one or more Application Load Balancers, Network Load Balancers, Gateway Load Balancers, target groups, listeners, or rules.

        Parameters:
        removeTagsRequest -
        Returns:
        Result of the RemoveTags operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        TargetGroupNotFoundException - The specified target group does not exist.
        ListenerNotFoundException - The specified listener does not exist.
        RuleNotFoundException - The specified rule does not exist.
        TooManyTagsException - You've reached the limit on the number of tags for this resource.
        TrustStoreNotFoundException - The specified trust store does not exist.
        See Also:
        AWS API Documentation

        Samples:
        • To remove tags from a load balancer
          This example removes the specified tag from the specified load balancer.
          AmazonElasticLoadBalancing client = AmazonElasticLoadBalancingClientBuilder.standard().build();
          RemoveTagsRequest request = new RemoveTagsRequest().withLoadBalancerNames("my-load-balancer").withTags(new TagKeyOnly().withKey("project"));
          RemoveTagsResult response = client.removeTags(request);
      • setSecurityGroups

        SetSecurityGroupsResult setSecurityGroups(SetSecurityGroupsRequest setSecurityGroupsRequest)

        Associates the specified security groups with the specified Application Load Balancer or Network Load Balancer. The specified security groups override the previously associated security groups.

        You can't perform this operation on a Network Load Balancer unless you specified a security group for the load balancer when you created it.

        You can't associate a security group with a Gateway Load Balancer.

        Parameters:
        setSecurityGroupsRequest -
        Returns:
        Result of the SetSecurityGroups operation returned by the service.
        Throws:
        LoadBalancerNotFoundException - The specified load balancer does not exist.
        InvalidConfigurationRequestException - The requested configuration is not valid.
        InvalidSecurityGroupException - The specified security group does not exist.
        See Also:
        AWS API Documentation
      • shutdown

        void shutdown()
        Shuts down this client object, releasing any resources that might be held open. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources. Once a client has been shutdown, it should not be used to make any more requests.
      • getCachedResponseMetadata

        ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request)
        Returns additional metadata for a previously executed successful request, typically used for debugging issues where a service isn't acting as expected. This data isn't considered part of the result data returned by an operation, so it's available through this separate, diagnostic interface.

        Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic information for an executed request, you should use this method to retrieve it as soon as possible after executing a request.

        Parameters:
        request - The originally executed request.
        Returns:
        The response metadata for the specified request, or null if none is available.
Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /