class InstanceTarget
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ElasticLoadBalancing.InstanceTarget |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancing#InstanceTarget |
Java | software.amazon.awscdk.services.elasticloadbalancing.InstanceTarget |
Python | aws_cdk.aws_elasticloadbalancing.InstanceTarget |
TypeScript (source) | aws-cdk-lib » aws_elasticloadbalancing » InstanceTarget |
Implements
ILoad, 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
| Name | Type | Description |
|---|---|---|
| connections | Connections | The network connections associated with this resource. |
| instance | Instance | Instance to register to. |
connections
Type:
Connections
The network connections associated with this resource.
instance
Type:
Instance
Instance to register to.
Methods
| Name | Description |
|---|---|
| attach | 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.

.NET
Go
Java
Python
TypeScript (