Prose\UsingEc2Instance::markAllVolumesAsDeleteOnTermination PHP Метод

markAllVolumesAsDeleteOnTermination() публичный Метод

    public function markAllVolumesAsDeleteOnTermination()
    {
        $this->requiresValidHost(__METHOD__);
        // what are we doing?
        $log = usingLog()->startAction("mark all volumes on EC2 VM '{$this->instanceName}' to be deleted on termination");
        // create a list of all of the volumes we're going to modify
        $ebsVolumes = array();
        foreach ($this->instance['BlockDeviceMappings'] as $origEbsVolume) {
            $ebsVolume = array('DeviceName' => $origEbsVolume['DeviceName'], 'Ebs' => array('DeleteOnTermination' => true));
            $ebsVolumes[] = $ebsVolume;
        }
        // get the AWS EC2 client to work with
        $ec2Client = fromAws()->getEc2Client();
        // let's mark all of the volumes as needing to be deleted
        // on termination
        $ec2Client->modifyInstanceAttribute(array('InstanceId' => $this->instance['InstanceId'], 'BlockDeviceMappings' => $ebsVolumes));
        // now, we need to make sure that actually worked
        $this->instance = fromEc2()->getInstance($this->instanceName);
        // var_dump("\n\n\nAFTER MODIFY INSTANCE ATTRIBUTE\n\n");
        // var_dump($this->instance);
        // that should be that
        $log->endAction();
    }