#!/usr/bin/php
<?php 
require_once "/opt/cloud/providers/ec2/include.php";
$data = aws_request(aws_profile(), "ec2 describe-key-pairs");
foreach ($data["KeyPairs"] as $pair) {
    echo $pair["KeyName"] . "\n";
}
#!/usr/bin/php
<?php 
require_once "/opt/cloud/providers/ec2/include.php";
if ($argc < 2) {
    die("usage: {$argv['0']} <ami-id> [...]\n");
}
$args = escapeshellarg($argv[1]);
for ($x = 2; $x < 64; $x++) {
    if (!empty($argv[$x])) {
        $args .= " " . escapeshellarg($argv[$x]);
    }
}
$data = aws_request(aws_profile(), "ec2 describe-images --image-ids {$args}");
foreach ($data["Images"] as $image) {
    $id = $image["ImageId"];
    $full = $image["Name"];
    $name = basename($full);
    echo "{$id} {$name}\n";
}
#!/usr/bin/php
<?php 
require_once "/opt/cloud/providers/ec2/include.php";
$data = aws_request(aws_profile(), "ec2 describe-security-groups");
foreach ($data["SecurityGroups"] as $group) {
    $name = $group["GroupName"];
    $vpcid = $group["VpcId"];
    $id = $group["GroupId"];
    echo "{$vpcid} {$id} {$name}\n";
}
#!/usr/bin/php
<?php 
require_once "/opt/cloud/providers/ec2/include.php";
$data = aws_request(aws_profile(), "ec2 describe-instances");
foreach ($data["Reservations"] as $reservation) {
    aws_decode_reservation($reservation);
}