public function getImageInfo(\Scalr_Environment $environment, $cloudLocation, $imageId)
{
$info = [];
$snap = $environment->aws($cloudLocation)->ec2->image->describe($imageId);
if ($snap->count() > 0) {
$sn = $snap->get(0);
if ($sn->imageState == ImageData::STATE_AVAILABLE) {
$info["name"] = $sn->name;
$info["architecture"] = $sn->architecture;
if ($sn->description) {
$info["description"] = $sn->description;
}
if ($sn->platform) {
// platform could be windows or empty string
$info["osFamily"] = $sn->platform;
}
if ($sn->rootDeviceType == "ebs" || $sn->rootDeviceType == "instance-store") {
$info["type"] = $sn->rootDeviceType;
if ($sn->virtualizationType == "hvm") {
$info["type"] .= "-hvm";
}
}
foreach ($sn->blockDeviceMapping as $b) {
if ($b->deviceName == $sn->rootDeviceName && $b->ebs) {
$info["size"] = $b->ebs->volumeSize;
$info["ec2VolumeType"] = $b->ebs->volumeType;
$info["ec2VolumeIops"] = $b->ebs->iops;
}
}
}
}
return $info;
}