aws-cdk-lib.aws_elasticloadbalancing.InstanceTarget

class InstanceTarget

LanguageType name
.NETAmazon.CDK.AWS.ElasticLoadBalancing.InstanceTarget
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancing#InstanceTarget
Javasoftware.amazon.awscdk.services.elasticloadbalancing.InstanceTarget
Pythonaws_cdk.aws_elasticloadbalancing.InstanceTarget
TypeScript (source)aws-cdk-lib » aws_elasticloadbalancing » InstanceTarget

Implements ILoadBalancerTarget, IConnectable

An EC2 instance that is the target for load balancing.

Example

declare const vpc: ec2.IVpc;
const lb = new elb.LoadBalancer(this, 'LB', {
  vpc,
  internetFacing: true,
});

// instance to add as the target for load balancer.
const instance = new ec2.Instance(this, 'targetInstance', {
  vpc: vpc,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
  machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 }),
});
lb.addTarget(new elb.InstanceTarget(instance));

Initializer

new InstanceTarget(instance: Instance)

Parameters

  • instance Instance — Instance to register to.

Create a new Instance target.

Properties

NameTypeDescription
connectionsConnectionsThe network connections associated with this resource.
instanceInstanceInstance to register to.

connections

Type: Connections

The network connections associated with this resource.


instance

Type: Instance

Instance to register to.

Methods

NameDescription
attachToClassicLB(loadBalancer)Attach load-balanced target to a classic ELB.

attachToClassicLB(loadBalancer)

public attachToClassicLB(loadBalancer: LoadBalancer): void

Parameters

  • loadBalancer LoadBalancer

Attach load-balanced target to a classic ELB.