API compatible with AWS EC2

Amazon EC2 (Amazon Elastic Compute Cloud)

Amazon EC2, or Amazon Elastic Compute Cloud, is one of the core services of Amazon Web Services. It is an elastic public cloud, where AWS EC2 instances, are VPS-type virtual servers.

The e24cloud API in conjunction with Amazon EC2

The AWS EC2-compatible API provides limited compatibility of the methods provided to manage virtual resources such as virtual machines, virtual disks, private networks. Each location has its own API endpoint:

  • Location: Poznań DC1 - https://eu-poland-1poznan.api.e24cloud.com
  • Location: Poznań DC2 - https://eu-poland-1poznan2.api.e24cloud.com

Example PHP code - AWS EC2 compatible APIs

Przykładowy kod PHP, korzystający z API zgodnym z EC2 z użyciem AWS-SDK for PHP.

Initialize the connection via API compatible with AWS EC2

$client = new \Aws\Ec2\Ec2Client([
    'version' => '2015-04-15',
    "credentials" => [
        "key" => " api key",
        "secret" => " api secret ",

     ],
    'region' => 'eu-poland-1poznan',
    'endpoint_provider' => function (array $params) {
       return ['endpoint' => 'https://'.$params['region'].'.api.e24cloud.com'];
    },

    'signature_provider' => function ($version, $service, $region) {
      return new \Aws\Signature\SignatureV2();
    },

]); 

Image listing via API compatible with AWS EC2

$result = $client->describeImages();

foreach($result['Images'] as $image) {
 echo "ImageId: ".$image['ImageId'].', Name: '.$image['Name'], PHP_EOL;
}

Creating a virtual machine via API compatible with AWS EC2

$result = $client->runInstances(array(
    'ImageId' => 'ami-000006d8', // ImageId z describeImages
    'MinCount' => 1,
    'MaxCount' => 1,
    'InstanceType' => 'm1.xlarge',
));

Listing virtual machines via API compatible with AWS EC2

$result = $client->describeInstances();

foreach($result['Reservations'] as $reservation) {
 foreach($reservation['Instances'] as $instance) {
  echo 'id: '.$instance['InstanceId'].', type: '.$instance['InstanceType'].', State: '.$instance['State']['Name'].', PublicIp: '.$instance['PublicIpAddress'], PHP_EOL;
 }
}

Shutting down the virtual machine via API compatible with AWS EC2

$client->stopInstances(array(
    'InstanceIds' => array('70b9e613-d01a-4581-b29f-ba4b6fcebae9')
));

Turning on the virtual machine via API compatible with AWS EC2

$client->startInstances(array(
    'InstanceIds' => array('70b9e613-d01a-4581-b29f-ba4b6fcebae9')
));

Deleting the virtual machine via API compatible with AWS EC2

$client->terminateInstances(array(
    'InstanceIds' => array('70b9e613-d01a-4581-b29f-ba4b6fcebae9')
));

Compatibility - available EC2 API calls

Since not all services available in e24cloud have their counterparts in the EC2 API call convention, not all calls are available. The following calls are available:

  • AllocateAddress, AssociateAddress, DescribeAddresses, ReleaseAddress, DisassociateAddress
  • AttachVolume, CreateVolume, DeleteVolume, DetachVolume
  • CreateSnapshot, DeleteSnapshot
  • DescribeInstances, RebootInstances, RunInstances, StartInstances, StopInstances, TerminateInstances
  • CreateKeyPair, DeleteKeyPair, DescribeKeyPairs, ImportKeyPair
  • CreateImage, DeregisterImage, DescribeImageAttribute, DescribeImages
  • DescribeAvailabilityZones, DescribeRegions