Open hsuantio opened 4 years ago
By way of demonstration:
$getEc2 = [scriptblock]{Get-EC2Instance @($cluster.Instances.InstanceId)}
while((& $getEc2).Instances.State.Name -ne 'running'){
Write-Host "Awaiting startup of all EC2 instances. Sleeping 5..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
}
Write-Host "$(Get-Date) : all nodes report running" -ForegroundColor Blue
With a corresponding waiter loop for .State.Name -ne 'terminated'
in teardown scripts.
Hello, thank you for your feedback! I totally agree that waiters are a cool and useful feature. This request is tracked in https://github.com/aws/aws-sdk-net/issues/1336 for the AWS SDK for .NET on top of which this module is implemented. As soon as we can implement waiters in the .NET SDK, we can work to add them here as well.
The way to do this in PowerShell is to add an -AsJob
parameter to the Cmdlet. When -AsJob
is specified, the Cmdlet would return a Job
object which would be manipulated with the standard Job cmdlets (Wait-Job,
Receive-Job`, etc.). Of course, as Matteo points out, the underlying functionality needs to be there.
CLI usage:
aws ec2 start-instances --instance-ids ${instanceId}
aws ec2 wait instance-status-ok --instance-ids ${instanceId}
What about behaving similar to the python aws cli?
Example Powershell usage:
Start-Ec2Instance -InstanceIds ${instanceIds}
Wait-Ec2Instance -Status Ok -InstanceIds ${instanceIds}
Agreed, why can't the powershell just do what the CLI does?
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
PowerShell needs to be revisited once the related .NET SDK issue https://github.com/aws/aws-sdk-net/issues/1336 is implemented.
Other AWS SDKs such as Python and Ruby have built-in waiters so developers don't have to write loop mechanism that waits until the action is completed.