I am trying to speed up the time it takes me to launch instances from a specific AMI using this AWS blog post as a starting point, however I am not sure how to grab the ID of the newly acquired Instance I have spun up using V3 of the PHP API (opposed to V2 in the blog post) so I can retrieve further information about the Instance (using the ID I would have retrieved)
<?php
require 'C:\wamp\bin\php\php5.5.12\vendor\autoload.php';
use Aws\Ec2\Ec2Client;
$ec2Client = \Aws\Ec2\Ec2Client::factory(array(
'region' => 'eu-west-1',
'version' => 'latest'
));
//Default vars
$aws_key = 'aws-ireland';
$ami_id = 'ami-000000';
$min_count = '1';
$max_count = '1';
$instance_type = 't2.micro';
$instance_region = 'eu-west-1b';
$server_name = 'API Test Server';
$result = $ec2Client->runInstances(array (
//Creating the instance
'KeyName' => $aws_key,
'ImageId' => $ami_id,
'MinCount' => $min_count,
'MaxCount' => $max_count,
'InstanceType' => $instance_type,
'Placement' => array('AvailabilityZone' => $instance_region),
));
//Wait for server to be created
//Return the instance ID
Following the blog post any further from this results in errors as the method waitUntilInstanceRunning doesn't exist in V3 of the API.
Aucun commentaire:
Enregistrer un commentaire