Skip to content
v2.278.0

InstanceTarget Class ​

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_elasticloadbalancingv2_targets as elasticloadbalancingv2_targets } from 'aws-cdk-lib';

declare const instance: ec2.Instance;
const instanceTarget = new elasticloadbalancingv2_targets.InstanceTarget(instance, /* all optional props */ 123);
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_elasticloadbalancingv2_targets as elasticloadbalancingv2_targets

# instance: ec2.Instance

instance_target = elasticloadbalancingv2_targets.InstanceTarget(instance, 123)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.elasticloadbalancingv2.targets.*;

Instance instance;

InstanceTarget instanceTarget = new InstanceTarget(instance, 123);
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ElasticLoadBalancingV2.Targets;

Instance instance;

var instanceTarget = new InstanceTarget(instance, 123);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var instance Instance

instanceTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewInstanceTarget(instance, jsii.Number(123))

Initializer ​

ts
new InstanceTarget(instance: Instance, port?: number)
python
InstanceTarget(instance: Instance, port: typing.Optional[int | float] = None)
java
new InstanceTarget(Instance instance, Number port)
csharp
new InstanceTarget(Instance instance, double? port = null)
go
NewInstanceTarget(Instance Instance, Port *float64)

Methods ​

attachToApplicationTargetGroup(targetGroup: IApplicationTargetGroup): LoadBalancerTargetPropsdef attach_to_application_target_group(self, target_group: IApplicationTargetGroup) -> LoadBalancerTargetPropspublic LoadBalancerTargetProps attachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)public LoadBalancerTargetProps AttachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)func AttachToApplicationTargetGroup(TargetGroup IApplicationTargetGroup) LoadBalancerTargetProps #
Register this instance target with a load balancer.

Don't call this, it is called automatically when you add the target to a load balancer.

attachToNetworkTargetGroup(targetGroup: INetworkTargetGroup): LoadBalancerTargetPropsdef attach_to_network_target_group(self, target_group: INetworkTargetGroup) -> LoadBalancerTargetPropspublic LoadBalancerTargetProps attachToNetworkTargetGroup(INetworkTargetGroup targetGroup)public LoadBalancerTargetProps AttachToNetworkTargetGroup(INetworkTargetGroup targetGroup)func AttachToNetworkTargetGroup(TargetGroup INetworkTargetGroup) LoadBalancerTargetProps #
Register this instance target with a load balancer.

Don't call this, it is called automatically when you add the target to a load balancer.