1. Go to this page and download the library: Download irap/ec2-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
irap / ec2-wrapper example snippets
ate the ec2 client.
$ec2Client = new iRAP\Ec2Wrapper\Ec2Client(
'myApiKey',
'myApiSecret',
\iRAP\Ec2Wrapper\Enums\AwsRegion::create_EU_W1()
);
$ubuntuImage = 'ami-cc166eb5';
$launchSpec = new \iRAP\Ec2Wrapper\Objects\LaunchSpecification(
\iRAP\Ec2Wrapper\Enums\Ec2InstanceType::createT2($size=1), // 1 = nano
$ubuntuImage,
"Name for my instance"
);
// launch 3 instances
$request = new iRAP\Ec2Wrapper\Requests\RequestRunInstances($launchSpec, 3, 3);
$launchResponse = $ec2client->launchInstances($request);
// get info on the instances we launched.
$launchedInstances = $launchResponse->getEc2Instances();
// Get all of our running instances...
$response = $ec2client->describeInstances();
$instances = $response->getEc2Instances();
// ...and terminate them.
foreach ($instances as $instance)
{
/* @var $instance \iRAP\Ec2Wrapper\Objects\Ec2Instance */
$instance->terminate($ec2client);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.