While I haven't seen this particular problem there is a high chance that this is a timing issue. It would be very easy to write code which creates something (target group in this case) and then tries to use that something (here, register targets with the target group) before the service control plane has had time to react.
Rather than just add a delay what I would do is query the service to see if the target group has been successfully created. If it hasn't, then wait (say, for a second) and try again. You might even perform an exponential backoff in that loop and have some condition for permanent failure (just in case).
There's an excellent article about this in the Amazon Builder's Library.
- asked 7 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 6 months ago
- EXPERTpublished 4 months ago
Thanks for this. I will give it a try.