This message was deleted.
# kubernetes
s
This message was deleted.
c
We had a similar issue waiting for instance refreshes after an ASG update, you could adapt this for what arbitrary you want to check if instances are up:
Copy code
async function waitForInstanceRefresh(name: string): Promise<boolean> {
  if (!pulumi.runtime.isDryRun()) {
    const credentials = fromNodeProviderChain({ profile: awsProfile });
    const config = { credentials, region: awsRegion };
    const autoScalingClient = new AutoScalingClient(config);

    const refreshCommand = new DescribeInstanceRefreshesCommand({
      AutoScalingGroupName: name,
      MaxRecords: 100,
    });

    await backOff(
      async () => {
        const { InstanceRefreshes } = await autoScalingClient.send(refreshCommand);
        const inProgress = InstanceRefreshes?.filter((e) => e.Status === 'InProgress');
        if (inProgress && inProgress.length === 0) {
          return true;
        } else if (inProgress) {
          throw Error(`ASG refresh still in progress`);
        } else {
          throw Error('ASG client failed?');
        }
      },
      {
        retry: async (e, attemptNumber) => {
          await <http://pulumi.log.info|pulumi.log.info>(`checking ASG refresh for ${name}: ${attemptNumber}`);
          return true;
        },
        numOfAttempts: 30,
        startingDelay: 10000,
        maxDelay: 60000,
        delayFirstAttempt: true,
        jitter: 'none',
      },
    );
  }
  return true;
}
then call this in an
apply
on some property before the thing you want to deploy, like
asg.name.apply((name) => waitForInstanceRefresh(name));