registerTargets
Registers the specified targets with the specified target group.
If the target is an EC2 instance, it must be in the running state when you register it.
By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports.
For more information, see the following:
Samples
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.TargetDescription
fun main() {
//sampleStart
// This example registers the specified instances with the specified target group.
elasticLoadBalancingV2Client.registerTargets {
targetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"
targets = listOf<TargetDescription>(
TargetDescription {
id = "i-80c8dd94"
},
TargetDescription {
id = "i-ceddcd4d"
}
)
}
//sampleEnd
}import aws.sdk.kotlin.services.elasticloadbalancingv2.model.TargetDescription
fun main() {
//sampleStart
// This example registers the specified instance with the specified target group using multiple ports.
// This enables you to register ECS containers on the same instance as targets in the target group.
elasticLoadBalancingV2Client.registerTargets {
targetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9"
targets = listOf<TargetDescription>(
TargetDescription {
id = "i-80c8dd94"
port = 80
},
TargetDescription {
id = "i-80c8dd94"
port = 766
}
)
}
//sampleEnd
}