0

I am using the latest PHP Toolkit provided by Amazon to manipulate my EC2 Instances

I use the following code to check if the drive is available or not

$this->client->waitUntil('__VolumeStatus', array(
        'VolumeIds' => array($volumeId),
        'waiter.success.value' => VolumeState::AVAILABLE
    ));

Problem is that there is no status defined as DELETED. Only available options are given below

class VolumeState extends Enum
{
  const CREATING = 'creating';
  const AVAILABLE = 'available';
  const IN_USE = 'in-use';
  const DELETING = 'deleting';
  const ERROR = 'error';
}

Is there a clean way to stop the PHP process until the drive is deleted?

Saqib
  • 2,470
  • 3
  • 19
  • 32

1 Answers1

2

The way EBS works is that once the volume is deleted you won't see it any more. Logically, there's no reason to have a "deleted" status. There is no notion of a "Soft Delete" or "Undelete", which is what would require a "Deleted" status.

The absence of the volume from the DescribeVolumes response would be how this would work at the EBS API layer: http://docs.aws.amazon.com/AWSSDKforPHP/latest/#m=AmazonEC2/describe_volumes

At the Web Service SDK level, EBS will return an Error if you try to describe a volume that doesn't exist. Due to my lack of PHP familiarity, I'm not sure how that translates in PHP.

A guess (from someone who has never written a line of PHP Code!) would be something like:

do {
  $response = $ec2->describe_volumes($volumeId);
} while (! $response.isOk)

This should be done using the "waiter" infrastructure in the SDK rather than in while loop as you're already doing for availability.

Chris M.
  • 1,731
  • 14
  • 15