Skip to content
v2.278.0

InstanceIdTarget Class ​

An EC2 instance that is the target for load balancing.

If you register a target of this type, you are responsible for making sure the load balancer's security group can connect to the instance.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_elasticloadbalancingv2_targets as elasticloadbalancingv2_targets } from 'aws-cdk-lib';
const instanceIdTarget = new elasticloadbalancingv2_targets.InstanceIdTarget('instanceId', /* 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_elasticloadbalancingv2_targets as elasticloadbalancingv2_targets

instance_id_target = elasticloadbalancingv2_targets.InstanceIdTarget("instanceId", 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.elasticloadbalancingv2.targets.*;

InstanceIdTarget instanceIdTarget = new InstanceIdTarget("instanceId", 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.ElasticLoadBalancingV2.Targets;

var instanceIdTarget = new InstanceIdTarget("instanceId", 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"

instanceIdTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewInstanceIdTarget(jsii.String("instanceId"), jsii.Number(123))

Initializer ​

ts
new InstanceIdTarget(instanceId: string, port?: number)
python
InstanceIdTarget(instance_id: str, port: typing.Optional[int | float] = None)
java
new InstanceIdTarget(String instanceId, Number port)
csharp
new InstanceIdTarget(string instanceId, double? port = null)
go
NewInstanceIdTarget(InstanceId *string, 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.