aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
238 stars 79 forks source link

Waiters feature request #52

Open hsuantio opened 4 years ago

hsuantio commented 4 years ago

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.

petervandivier commented 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.

matteo-prosperi commented 4 years ago

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.

BrucePay commented 4 years ago

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.

pjmagee commented 4 years ago

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}
richardgavel commented 3 years ago

Agreed, why can't the powershell just do what the CLI does?

github-actions[bot] commented 2 years ago

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.

ashishdhingra commented 1 year ago

PowerShell needs to be revisited once the related .NET SDK issue https://github.com/aws/aws-sdk-net/issues/1336 is implemented.