【发布时间】:2015-09-11 23:00:06
【问题描述】:
我正在尝试加快从特定 AMI 启动实例所需的时间,使用 this AWS 博客文章作为起点,但是我不确定如何获取我拥有的新获取的实例的 ID使用 PHP API 的 V3(与博客文章中的 V2 相对)启动,因此我可以检索有关实例的更多信息(使用我将检索到的 ID)
<?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
继续阅读博客文章会导致错误,因为方法 waitUntilInstanceRunning 在 API 的 V3 中不存在。我认为我需要使用服务员,但我不确定如何使用它来解决我的问题?
【问题讨论】:
标签: php amazon-web-services amazon-ec2 aws-sdk