Esempio n. 1
0
    $running = $state == 'running';
    if (!$running) {
        print "Instance is currently in " . "state {$state}, waiting 10 seconds\n";
        sleep(10);
    }
} while (!$running);
// Allocate an Elastic IP address
$res = $ec2->allocate_address();
if (!$res->isOK()) {
    exit("Could not allocate public IP address.\n");
}
// Get the allocated Elastic IP address
$publicIP = (string) $res->body->publicIp;
print "Assigned IP address {$publicIP}.\n";
// Associate the Elastic IP address with the instance
$res = $ec2->associate_address($instanceId, $publicIP);
if (!$res->IsOK()) {
    exit("Could not associate IP address {$publicIP} " . "with instance {$instanceId}.\n");
}
print "Associated IP address {$publicIP} " . "with instance {$instanceId}.\n";
// Create two EBS volumes in the instance's availability zone
$opt = array();
$opt['Size'] = 1;
$res1 = $ec2->create_volume($availabilityZone, $opt);
$res2 = $ec2->create_volume($availabilityZone, $opt);
if (!$res1->isOK() || !$res2->isOK()) {
    exit("Could not create EBS volumes.\n");
}
// Get the volume Ids
$volumeId1 = (string) $res1->body->volumeId;
$volumeId2 = (string) $res2->body->volumeId;