I have used this code to create aws lightsail instance using php code.
$client->createInstances([
'addOns' => [
[
'addOnType' => 'AutoSnapshot',
'autoSnapshotAddOnRequest' => [
'snapshotTimeOfDay' => config('aws.snapshotTime'),
],
],
],
'availabilityZone' => config('aws.instanceAvailabilityZone'),
'blueprintId' => config('aws.os'),
'bundleId' => config('aws.instanceType'),
'instanceNames' => ['testinstance],
'userData' => config('aws.afterInstallScript'),
]);
return $result = $client->getInstanceState([
'instanceName' => $instanceName
]);
The code is executed with instance state pending. But my requirement is that it should return when the instance state is running. Aws SDK has waitUntil() function but I don't know how to use this in lightsail.
Can anyone help me with this?