I'm trying to register a new EC2 instance with an ELBV2. I'm trying from the AWSPowershell Module but cannot get it to work.
$InstanceId = (Invoke-WebRequest 'http://169.254.169.254/latest/meta-data/instance-id').Content
Register-ELB2Target -TargetGroupArn 'arn:etc...' -Target $InstanceID
The error is:
Register-ELB2Target : Cannot bind parameter 'Target'. Cannot convert the "i-redacted" value of type "System.String" to type
"Amazon.ElasticLoadBalancingV2.Model.TargetDescription".
I've checked the documentation, and can see that it can take a port too (optional). Have tried adding the port, but still no luck.
You're not creating the TargetDescription object correctly, it should be something like:
For anyone else who arrives here looking for an easy answer, we use the following script for instances to register themselves with the ALB when new packages are deployed: