使用 CLI 等待操作完成

Wait for an operation to finish using CLI

我有 CodeBuild 运行“aws apprunner start-deployment”,但我不希望在部署完成之前完成代码构建。在 docs 中,它表示 ...

This is an asynchronous operation. On a successful call, you can use the returned OperationId and the ListOperations call to track the operation’s progress.

但我不确定具体该怎么做。

将输出分配给一个变量。然后用list-operations运算看是否还是运行.

id=$(aws apprunner start-deployment)
while aws apprunner list-operations | grep -q "$id"; do
    sleep 1
done