cool-scientist-53915
06/16/2023, 1:12 PMaws.ec2.Instance
to be in a running state before attempting to do a command.remote.Command
on that host.echoing-dinner-19531
06/16/2023, 1:44 PMcool-scientist-53915
06/16/2023, 2:22 PMasync function waitForInstance(id: string) {
if (pulumi.runtime.isDryRun()) {
return;
}
// Wait for up to 10 minutes
for (let i = 0; i < 60; i++) {
let instance = await aws.ec2.getInstance({ instanceId: id });
if (instance.instanceState === "running") {
return instance;
}
pulumi.log.info(`Waiting for Instance to start (${id})`);
// Wait for 10s between polls
await new Promise((r) => setTimeout(r, 10000));
}
throw new Error("timed out waiting for Instance to start");
}
echoing-dinner-19531
06/16/2023, 2:23 PM