Back to Aws Sdk Js V3

@aws-sdk/client-elastic-load-balancing

clients/client-elastic-load-balancing/README.md

3.1043.022.8 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-elastic-load-balancing

Description

AWS SDK for JavaScript ElasticLoadBalancing Client for Node.js, Browser and React Native.

<fullname>Elastic Load Balancing</fullname>

<p>A load balancer can distribute incoming traffic across your EC2 instances. This enables you to increase the availability of your application. The load balancer also monitors the health of its registered instances and ensures that it routes traffic only to healthy instances. 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 and a protocol and port number for connections from the load balancer to the instances.</p> <p>Elastic Load Balancing supports three types of load balancers: Application Load Balancers, Network Load Balancers, and Classic Load Balancers. You can select a load balancer based on your application needs. For more information, see the <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/">Elastic Load Balancing User Guide</a>.</p> <p>This reference covers the 2012-06-01 API, which supports Classic Load Balancers. The 2015-12-01 API supports Application Load Balancers and Network Load Balancers.</p> <p>To get started, create a load balancer with one or more listeners using <a>CreateLoadBalancer</a>. Register your instances with the load balancer using <a>RegisterInstancesWithLoadBalancer</a>.</p> <p>All Elastic Load Balancing operations are <i>idempotent</i>, which means that they complete at most one time. If you repeat an operation, it succeeds with a 200 OK response code.</p>

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-elastic-load-balancing
  • yarn add @aws-sdk/client-elastic-load-balancing
  • pnpm add @aws-sdk/client-elastic-load-balancing

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the ElasticLoadBalancingClient and the commands you need, for example DescribeAccountLimitsCommand:

js
// ES5 example
const { ElasticLoadBalancingClient, DescribeAccountLimitsCommand } = require("@aws-sdk/client-elastic-load-balancing");
ts
// ES6+ example
import { ElasticLoadBalancingClient, DescribeAccountLimitsCommand } from "@aws-sdk/client-elastic-load-balancing";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new ElasticLoadBalancingClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new DescribeAccountLimitsCommand(params);

Async/await

We recommend using the await operator to wait for the promise returned by send operation as follows:

js
// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Promises

You can also use Promise chaining.

js
client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

ElasticLoadBalancing extends ElasticLoadBalancingClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (ElasticLoadBalancingClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { ElasticLoadBalancing } from "@aws-sdk/client-elastic-load-balancing";

const client = new ElasticLoadBalancing({ region: "REGION" });

// async/await.
try {
  const data = await client.describeAccountLimits(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .describeAccountLimits(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.describeAccountLimits(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

js
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-elastic-load-balancing package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<details> <summary> AddTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ApplySecurityGroupsToLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> AttachLoadBalancerToSubnets </summary>

Command API Reference / Input / Output

</details> <details> <summary> ConfigureHealthCheck </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateAppCookieStickinessPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateLBCookieStickinessPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateLoadBalancerListeners </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateLoadBalancerPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteLoadBalancerListeners </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteLoadBalancerPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeregisterInstancesFromLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeAccountLimits </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeInstanceHealth </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeLoadBalancerAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeLoadBalancerPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeLoadBalancerPolicyTypes </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeLoadBalancers </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> DetachLoadBalancerFromSubnets </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisableAvailabilityZonesForLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableAvailabilityZonesForLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> ModifyLoadBalancerAttributes </summary>

Command API Reference / Input / Output

</details> <details> <summary> RegisterInstancesWithLoadBalancer </summary>

Command API Reference / Input / Output

</details> <details> <summary> RemoveTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetLoadBalancerListenerSSLCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetLoadBalancerPoliciesForBackendServer </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetLoadBalancerPoliciesOfListener </summary>

Command API Reference / Input / Output

</details>