Update sendCommand to use WaitGroup
WilboMo opened this issue · comments
Will Moore commented
If instanceIDs
is large, there's a reasonable chance that some command executions will complete sooner than others, and it's possible that some might take so much time that the service-side record of the command might be garbage-collected before we retrieve the execution status.
// Wait for the sent commands to complete
wg := sync.WaitGroup{}
for _, v := range instanceIDs {
wg.Add(1)
go func(instanceID string) {
ssmClient.WaitUntilCommandExecuted(&ssm.GetCommandInvocationInput{
CommandId: aws.String(commandID),
InstanceId: aws.String(instanceID),
})
wg.Done()
}(aws.StringValue(v))
}
wg.Wait()
Originally posted by @samuelkarp in #34 (comment)