New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
5
Versions
442
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

AWS SDK for JavaScript Elastic Load Balancing V2 Client for Node.js, Browser and React Native

3.521.0
Source
npm
Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created

What is @aws-sdk/client-elastic-load-balancing-v2?

@aws-sdk/client-elastic-load-balancing-v2 is an AWS SDK for JavaScript package that allows developers to interact with the Elastic Load Balancing (ELB) service, specifically the Application Load Balancer (ALB) and Network Load Balancer (NLB). It provides a set of APIs to manage load balancers, target groups, listeners, and rules.

What are @aws-sdk/client-elastic-load-balancing-v2's main functionalities?

Create Load Balancer

This feature allows you to create a new load balancer. The code sample demonstrates how to create an Application Load Balancer with specified subnets, security groups, and other configurations.

const { ElasticLoadBalancingV2Client, CreateLoadBalancerCommand } = require('@aws-sdk/client-elastic-load-balancing-v2');

const client = new ElasticLoadBalancingV2Client({ region: 'us-west-2' });

const params = {
  Name: 'my-load-balancer',
  Subnets: ['subnet-12345678'],
  SecurityGroups: ['sg-12345678'],
  Scheme: 'internet-facing',
  Type: 'application'
};

const command = new CreateLoadBalancerCommand(params);

client.send(command).then(
  (data) => console.log(data),
  (error) => console.error(error)
);

Create Target Group

This feature allows you to create a new target group. The code sample demonstrates how to create a target group with specified protocol, port, and VPC ID.

const { ElasticLoadBalancingV2Client, CreateTargetGroupCommand } = require('@aws-sdk/client-elastic-load-balancing-v2');

const client = new ElasticLoadBalancingV2Client({ region: 'us-west-2' });

const params = {
  Name: 'my-target-group',
  Protocol: 'HTTP',
  Port: 80,
  VpcId: 'vpc-12345678'
};

const command = new CreateTargetGroupCommand(params);

client.send(command).then(
  (data) => console.log(data),
  (error) => console.error(error)
);

Register Targets

This feature allows you to register targets with a target group. The code sample demonstrates how to register EC2 instances with a specified target group.

const { ElasticLoadBalancingV2Client, RegisterTargetsCommand } = require('@aws-sdk/client-elastic-load-balancing-v2');

const client = new ElasticLoadBalancingV2Client({ region: 'us-west-2' });

const params = {
  TargetGroupArn: 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-target-group/abcdef123456',
  Targets: [
    { Id: 'i-12345678' },
    { Id: 'i-87654321' }
  ]
};

const command = new RegisterTargetsCommand(params);

client.send(command).then(
  (data) => console.log(data),
  (error) => console.error(error)
);

Create Listener

This feature allows you to create a listener for a load balancer. The code sample demonstrates how to create an HTTP listener that forwards requests to a specified target group.

const { ElasticLoadBalancingV2Client, CreateListenerCommand } = require('@aws-sdk/client-elastic-load-balancing-v2');

const client = new ElasticLoadBalancingV2Client({ region: 'us-west-2' });

const params = {
  LoadBalancerArn: 'arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/abcdef123456',
  Protocol: 'HTTP',
  Port: 80,
  DefaultActions: [
    {
      Type: 'forward',
      TargetGroupArn: 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-target-group/abcdef123456'
    }
  ]
};

const command = new CreateListenerCommand(params);

client.send(command).then(
  (data) => console.log(data),
  (error) => console.error(error)
);

Other packages similar to @aws-sdk/client-elastic-load-balancing-v2

FAQs

Package last updated on 23 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts